I have a docker app and it works on http:// localhost:8000. This app also works on http://my_domain.com. I would like to run my docker app through nginx reverse proxy. Therefore, I have done the following.
$ docker run -d --rm -p 8000:8000 my_app
$ curl http://localhost:8000
$ sudo nano /etc/nginx/sites-available/my_domain.com
The file my_domain.com contains the following:
server {
server_name my_domain.com;
index index.html index.htm;
access_log /var/log/nginx/my_app.log;
error_log /var/log/nginx/my_app-error.log error;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
}
}
Then, I have written the following on the command line:
$ sudo ln -s /etc/nginx/sites-available/my_domain.com /etc/nginx/sites-enabled/my_domain.com
$ sudo nginx -t
$ sudo nginx -s reload
Everything seems ok, but when I visit http://my_domain.com, I see the nginx default page with: Welcome to nginx! Unfortunately, I cannot see my app running as I saw on http:// localhost:8000 or on http://my_domain.com before the above operation.