gpt4 book ai didi

apache - 为什么 :8080 works while 不适用于在 Ec2 上运行的 tomcat 服务器?

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

我的 webapp 在 Tomcat 上运行,Tomcat 在 EC2 实例上运行。我已正确设置实例的入站规则。

当我输入 <myWebsite.com>:8080它适用于我的浏览器。对于 <myWebsite.com>它不加载。相反,我收到以下错误消息:

This site can’t be reached <myWebsite.com> refused to connect.
Search Google for <my Website> home
ERR_CONNECTION_REFUSED

最佳答案

当您尝试通过 myWebsite.com 直接连接时,您的浏览器将默认使用端口 80 上的 http。显然,您的网络服务器正在监听端口 8080。

您需要配置 Tomcat 以监听端口 80 上的传入请求。

stackoverflow上有很多关于如何将tomcat端口从8080更改为80的教程和问题。

例如来自 How to change the port of Tomcat from 8080 to 80? :

1) Go to conf folder in tomcat installation directory

e.g. C:\Tomcat 6.0\conf\

2) Edit following tag in server.xml file

3) Change the port=8080 value to port=80

4) Save file.

5) Stop your Tomcat and restart it.

请记住,默认情况下,Tomcat 不会在端口 80 上启动,除非以 root 身份运行。但是,以 root 身份运行通常被认为是不好的做法。以下资源很好地总结了如何使用 Tomcat 和 EC2 缓解此问题: https://www.excelsior-usa.com/articles/tomcat-amazon-ec2-advanced.html#port80

最简单的解决方案是通过 iptables 重定向 tomcat 端口(例如 8080):

sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo /sbin/service iptables save

关于apache - 为什么 <myWebsite.com> :8080 works while <mywebsite. com> 不适用于在 Ec2 上运行的 tomcat 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55137358/

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