0

I have a VPS Linux (Ubuntu) server with specific IP and I would like to run my app on my own domain http://my_domain.com. I have built a docker container and it works well on localhost 0.0.0.0:80. Then, I guess I have to configure nginx to connect my domain to the server IP.

I have configured nginx in a similar way like How can I forward requests from my web server? , but using https://cran.r-project.org/web/packages/ReviewR/vignettes/deploy_server.html#configuring-nginx-to-reverse-proxy-shiny-server , i.e.


$ sudo nano /etc/nginx/sites-available/shiny

server {

        server_name my_domain.com;

        location / {
                proxy_pass http://localhost:80;
                proxy_redirect / $scheme://$http_host/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
                proxy_read_timeout 20d;
                proxy_buffering off;
        }
}

However, I have got the following:

$ sudo systemctl reload nginx

nginx.service is not active, cannot reload

Then, I have written:

$ sudo service nginx start
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

Additionally, I have written:

$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2022-05-15 18:53:40 CEST; 11s ago

Finally, I have written:

$ sudo nginx -t
nginx: [emerg] unknown "connection_upgrade" variable
nginx: configuration file /etc/nginx/nginx.conf test failed

However, if I navigate to my_server_ip, I can see my app running. If I navigate to http://my_domain.com, I can see the hosting provider default page, I cannot see my app running.

I would like to know how to run my app on my own domain.

Citizen
  • 1
  • 1
  • 1
    Broadly speaking you don't *run* an docker container on a domain. It listens to an IP address. DNS may point to IP addresses. – vidarlo May 15 '22 at 13:17
  • Does this answer your question? [How can I forward requests from my web server?](https://serverfault.com/questions/1035016/how-can-i-forward-requests-from-my-web-server) – Gerald Schneider May 15 '22 at 13:26

1 Answers1

0

Add the following section to your nginx configuration:

map $http_upgrade $connection_upgrade {  
    default upgrade;
    ''      close;
}
  • I have added the section after location / { ... } how I described above, in /etc/nginx/sites-available/shiny, and it does not work. Then, I have added your section after the mail section in /etc/nginx/nginx.conf, but it does not work. – Citizen May 17 '22 at 05:03