问题
I want to run three subdomains on the same server and the same service in a different folder all this are Django service.
bellow is the Nginx conf file
I am trying to run request-micro service on the same server with a different domains and different folders.
I am already running two test server domain on 2732 port in "home/user/test/" folder and its running fine,
Now I am trying to run dev server on 2742 port in different directory "/home/user/dev/" but some times the test server requests are coming on dev server ports.it should be on 2732.
test.buyer1.domain.co should redirect to 2732 and dev.buyer2.domain.co should redirect to 2742 port but sometimes test.buyer1.domain.co redirects to 2742.
how can I differentiate dev and test server?
server {
server_name test.buyer1.domain.co ;
location /request-micro {
allow all;
proxy_pass http://127.0.0.1:2732;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
client_max_body_size 2000M;
alias /home/ubuntu/test/project/project;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/test.buyer1.domain.co/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.buyer1.domain.co/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
server_name test.buyer2.domain.co ;
location /request-micro {
allow all;
proxy_pass http://127.0.0.1:2732;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
client_max_body_size 2000M;
alias /home/ubuntu/test/project/project;
}
listen 443 ssl; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/test.buyer2.domain.co/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.buyer2.domain.co/privkey.pem; # managed by Certbot
}
server {
server_name dev.buyer2.domain.co ;
location /request-micro {
allow all;
proxy_pass http://127.0.0.1:2742;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
client_max_body_size 2000M;
alias /home/ubuntu/dev/project/project;
}
listen 443 ssl; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/dev.buyer2.domain.co/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dev.buyer2.domain.co/privkey.pem; # managed by Certbot
}
server {
if ($host = test.buyer1.domain.co) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name test.buyer1.domain.co ;
listen 80;
return 404; # managed by Certbot
}
server {
if ($host = test.buyer2.domain.co) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name test.buyer2.domain.co ;
listen 80;
return 404; # managed by Certbot
}
server {
if ($host = dev.buyer2.domain.co) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name dev.buyer2.domain.co ;
listen 80;
return 404; # managed by Certbot
}
what should I do?
来源:https://stackoverflow.com/questions/63148739/running-multiple-django-project-on-same-ubuntu-instance-using-nginx-as-a-proxy-s