0

I want to run multiple websites on the same django app and the same nginx server. I am successfully running http: //myip/ and http: //myip/name1 and http: //myid/name2

Now I want to link all these projects to myname.com and name1.com and name2.com

How should I change my nginx config file? The current version of the file is shown below. Thanks

upstream crsq {
      server localhost:8000;
}

server {

    listen 80 default;

    access_log /home/ubuntu/crsq-access.log;
    error_log /home/ubuntu/crsq-error.log error;

    # Make site accessible from http://localhost/
    server_name crsq;

    location @proxy_to_crsq_app {
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
        proxy_set_header X-Forwarded-For $http_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http: //crsq;
    }

    location /robots.txt {
        alias /home/ubuntu/crsq/crsq/robots.txt;
    }


    location / {
        try_files $uri @proxy_to_crsq_app;
    }

    location /static {
        alias /home/ubuntu/crsq/crsq/static;
    }
}

1 Answer 1

1
upstream crsq {
      server localhost:8000;
}

server {

    listen 80 ;

    access_log /home/ubuntu/crsq-access.log;
    error_log /home/ubuntu/crsq-error.log error;

    # Make site accessible from http://localhost/
    server_name a.b.c;

    location @proxy_to_crsq_app {
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
        proxy_set_header X-Forwarded-For $http_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http: //crsq;
    }

    location /robots.txt {
        alias /home/ubuntu/crsq/crsq/robots.txt;
    }


    location / {
        try_files $uri @proxy_to_crsq_app;
    }

    location /static {
        alias /home/ubuntu/crsq/crsq/static;
    }
}
server {

    listen 80 ;

    access_log /home/ubuntu/crsq-access.log;
    error_log /home/ubuntu/crsq-error.log error;

    # Make site accessible from http://localhost/
    server_name b.c.d;

    location @proxy_to_crsq_app {
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
        proxy_set_header X-Forwarded-For $http_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http: //crsq;
    }

    location /robots.txt {
        alias /home/ubuntu/crsq/crsq/robots.txt;
    }


    location / {
        try_files $uri @proxy_to_crsq_app;
    }

    location /static {
        alias /home/ubuntu/crsq/crsq/static;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.