gpt4 book ai didi

tomcat - 项目路径在 nginx -tomcat 中用作域

转载 作者:行者123 更新时间:2023-11-28 22:28:41 24 4
gpt4 key购买 nike

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;
}
}

最佳答案

    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;
}
}

关于tomcat - 项目路径在 nginx -tomcat 中用作域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31405063/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com