gpt4 book ai didi

java - 域名+nginx+tomcat设置

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

我创建了一个域名并将其重新定义为您的外部 IP 地址。同时启动 nginx 和 tomcat。将域重新定义为外部 IP 地址。

truckpart4you.com:8081/spring

我想隐藏8081端口和包/spring/

现在我有一些设置nginx.conf

    server {
listen 81;
server_name www.truckpart4you.com truckpart4you.com;

access_log logs/host.access.log main;

location / {

proxy_pass localhost:81/;
proxy_redirect off;

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

server.xml(用于tomcat)

      <Host name="localhost"  appBase="webapps"
unpackWARs="true" autoDeploy="true"/>

如何为vindovs配置nginx和tomcat?

最佳答案

Nginx 配置:

server {
listen 81; # why 81 instead of 80???
server_name www.truckpart4you.com truckpart4you.com;

access_log logs/host.access.log main;

location / {

proxy_pass http://localhost:8081;

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

您的应用程序应部署在根目录中,即 http://localhost:8081/而不是 http://localhost:8081/spring/.您可以通过在标记内的 server.xml 文件中添加一个部分来轻松地做到这一点。

<Context path="" docBase="<YOUR APP>" debug="0" reloadable="true">

关于java - 域名+nginx+tomcat设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27248163/

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