在 nginx 代理中设置 Tomcat [英] Setting up Tomcat in nginx proxy
问题描述
我正在设置我的网络服务器,我需要在 http://ip/tomcat/
而不是 http://ip:8080/
上运行 tomcat.我如何在 nginx 上做到这一点?我试图在互联网上找到答案,但对我来说都是无用的.
我的nginx配置:
上游 tomcat {服务器ip:8080;}服务器 {听 80 default_server;听 [::]:80 default_server;服务器名称 _;位置/tomcat/{proxy_pass http://tomcat;}}
服务器回答:服务器回答图片
你可以使用/tomcat/location 和下面的标签.
location/tomcat/{proxy_pass http://tomcat/;}
当您要访问管理器页面时,它会打开 http://IP/manager 而不是 http://IP/tomcat/manager 导致/manager/html 在 tomcat webapps/ROOT/index.jsp 中被加固
如果您想通过 tomcat 位置访问管理器,请在 tomcat ROOT/index.jsp 中更改以下代码
重启tomcat并测试.
I'm setting up my web server and I need to run tomcat on http://ip/tomcat/
instead of http://ip:8080/
. How I can do this on nginx?
I've tried to find an answer in the internet, but all of them is useless for me.
My nginx configuration:
upstream tomcat {
server ip:8080;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location /tomcat/ {
proxy_pass http://tomcat;
}
}
Server answer: server answer image
You can use /tomcat/ location with using below tag.
location /tomcat/ {
proxy_pass http://tomcat/;
}
When you are going to access manager page it opens http://IP/manager instead of http://IP/tomcat/manager cause /manager/html is harded in tomcat webapps/ROOT/index.jsp
<div class="button">
<a class="container shadow" href="/manager/html"><span>Manager App</span></a>
</div>
If you want to access manager through tomcat location then change below code in tomcat ROOT/index.jsp
<div class="button">
<a class="container shadow" href="/tomcat/manager/html"><span>Manager App</span></a>
</div>
Restart tomcat and test.
这篇关于在 nginx 代理中设置 Tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!