Hi i am triying to intall 3 Projects in my droplet with nginx and gunicorn, i have 2 projects created with django and one with only html (a static website), i could install the static website listen the 80 port, also, i could put one django project but listen 8082 port, because when i put it to listen the 80 port only i could see the static website, so my question is, i have to change the port each time i going to install a new project or web site? and how i can install 2 django projects In a same droplet ?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!
In order to have more than one Django app listening on port 80, you’ll need to allow Nginx to direct requests to the correct app. You’ll also need to set up DNS records. By setting the
server_name
directive in each of your server blocks, Nginx will know what to serve.Here’s a simplified example:
In the example, requests to
example.com
will serve static content from/var/www//html
One toapp1.example.com
will serve a Django app listening on port 9000 andapp2.example.com
will serve the app listening on port 7000.You can get more info on how to use Nginx server block in this tutorial:
And on using Django with Nginx: