我正在使用 nginx 和 docker 来托管应用程序,conf 文件是:
server {
listen 80;
client_max_body_size 10M;
root /www/data;
location /static {
alias /var/www/static;
}
location /media {
alias /var/www/media;
}
location ~* ^/(api|admin) {
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_pass http://django:8000;
}
location /gateway {
proxy_http_version 1.1;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://nodejs:3000;
}
然后我们希望所有调用都重定向到新路径而不是子域。就像之前的域是类似 sub.example.com 的东西,但我们需要让它像 www.example.com/sub。我尝试更改 server_name,但它不起作用。