spring java项目在我的服务器上运行。我添加了新域名,但是当点击链接时,它会转到http://127.0.0.1:8081/而不是example.com
server {
listen 80;
server_name www.example.com example.com;
root /opt/appserv/travel_server/webapps/example;
location ~* \.(js|jpg|png|css)$ {
root /opt/appserv/travel_server/webapps/example/;
expires 30d;
}
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8081/example;
}
}
答案 0 :(得分:0)
server {
listen 80;
server_name www.example.com example.com
#server_name_in_redirect off;
root /opt/appserv/travel_server/webapps/example;
location ~* \.(js|jpg|png|css)$ {
root /opt/appserv/travel_server/webapps/example/;
expires 30d;
}
location ~* ^/(.*) {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8081/example/$1;
}
}