[Answered ]-Multiple Django app using nginx and gunicorn on Ubuntu 14.04 trusty server

1👍

You configured nginx to serve myapp2.com on port 8000:

server {
    listen 8000;
    server_name myapp2.com;
    # ...
}

so why would you expect nginx to serve it on port 80 ?

[edit] I thought the above was enough to make the problem clear but obviously not, so let’s start again:

You configured nginx to serve myapp2.com on port 8000 (the listen 8000; line in your conf, so nginx do what you asked for: it serves myapp2.com on port 8000.

If you want nginx to serve myapp2.com on port 80 (which is the implied default port for http so you don’t have to specify it explicitely in your url – IOW ‘http://myapp2.com/‘ is a shortcut for ‘http://myapp2.com:80/‘), all you have to do is to configure nginx to serve it on port 80 just like you did for ‘myapp.com’: replace listen 8000; by listen 80;.

1👍

If you don’t type in a port, your client will automatically use port 80.

Typing myapp2.com is the same as typing myapp2.com:80

But myapp2.com is not running on port 80, it’s running on port 8000.

When you go into production it is possible to redirect myapp2.com to port 8000 without explicitly typing it. You register myapp2.com with a DNS name server and point it towards myapp2.com:8000

Leave a comment