Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
How to host 2 Django Application using gunicorn & nginx in Production

Hello I want to host 2 djagno websites using Gunicorn and Nginx and I don't know how to do this this is my first time to host 2 django websites in one server and 2 domain so please tell me how to host 2 django website. Here is my 1 file located /var/www/site1 and here is my 2 file /var/www/site2

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Assuming you run your gunicorn instances on ports 8081 and 8082, you have two options:

Option 1: Subdomains

To use subdomains to reverse-proxy with NGINX, see this answer.

http://site1.example.com/ redirects to Site 1 and http://site2.example.com/ to Site 2.

NGINX config:

server {
    listen 80;
    server_name site1.example.com;
    location / {
        proxy_pass http://127.0.0.1:8082;
    }
}
server {
    listen 80;
    server_name site2.example.com;
    location / {
        proxy_pass http://127.0.0.1:8082;
    }
}

Option 2: Locations

http://example.com/site1/ now redirects to Site 1 and http://example.com/site2/ to Site 2.

NGINX config:

server {
    listen 80;
    server_name example.com;
    location /site1/ {
        proxy_pass http://127.0.0.1:8081;
    }
    location /site2/ {
        proxy_pass http://127.0.0.1:8082;
    }
}

EDIT - Option 3: Domains

You can also just use different domains for the different sites just as in option 1.

http://site1.com/ redirects to Site 1 and http://site2.com/ to Site 2.

NGINX config:

server {
    listen 80;
    server_name site1.com;
    location / {
        proxy_pass http://127.0.0.1:8082;
    }
}
server {
    listen 80;
    server_name site2.com;
    location / {
        proxy_pass http://127.0.0.1:8082;
    }
}

Note: These are bare minimum setups and may need additional configuration to work with your specific services.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!