简体   繁体   English

Java Web应用程序托管

[英]Java web application hosting

I hosted my application into Tomcat server and configured server.xml so that i can access my web application by directly accessing the website name eg:www.example.com but it works only when it is followed by my port number for eg: www.example.com:8080, I am using godaddy for VPS. 我将应用程序托管到Tomcat服务器中,并配置了server.xml,这样我可以通过直接访问网站名称(例如:www.example.com)来访问我的Web应用程序,但是仅当其后跟我的端口号(例如:www)时,它才有效。 example.com:8080,我正在将Godaddy用于VPS。

This is the configuration i have used 这是我使用的配置

  <Host name="example.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
  <Alias>www.example.com</Alias>
  <Context path="" docBase="Prototype" debug="0" privileged="true" />
  <Valve className="org.apache.catalina.valves.AccessLogValve"
         directory="logs"   prefix="localhost_access_log." suffix=".txt"
         pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/></host> 

but it works only when it is followed by my port number for eg: www.example.com:8080 但仅当其后跟我的端口号时,它才起作用,例如:www.example.com:8080

By 'works' , do you mean Tomcat starts with any port you mention in config but site can be accessed via 8080 only? 通过“ works”,您是说Tomcat以您在config中提到的任何端口开头,但是只能通过8080访问站点吗?

if not sure, refer to <tomcat_dir>/logs/catalina.out file to view startup logs, 如果不确定,请参考<tomcat_dir>/logs/catalina.out文件以查看启动日志,

it so may happen that your VPS has any other application already running on port 80 , httpd typically or NGINX in some cases, you need to stop the app and start tomcat with port 80 in config. 因此,您的VPS可能已经在端口80(通常是httpd或NGINX)上运行了任何其他应用程序,您需要停止该应用程序,并在配置中使用端口80启动tomcat。

how to check app running on specific port 如何检查特定端口上运行的应用程序

netstat -apn|grep <port_number>

or 要么

ss -apn|grep <port_number>

in case no app are running on port 80 or any other port you've mentioned in config and tomcat boots successfully, still you are not able to access your app via outside then most likely its network access issue, 如果没有应用程序在端口80或您在config和tomcat中提到的其他任何端口上成功运行,则仍然无法通过外部访问您的应用程序,很有可能是其网络访问问题,

for that you need to allow INGRESS access to your desired port in local IP Tables or Godaddy VPS config panel whichever the case may be. 为此,无论哪种情况,您都需要允许INGRESS访问本地IP表或Godaddy VPS配置面板中的所需端口。

the issue you have mentioned looks more like a linux admin issue. 您提到的问题看起来更像是Linux管理员问题。 please share more details i will guide you to exact solution 请分享更多详细信息,我将指导您找到确切的解决方案

All the best. 祝一切顺利。

You could provide som more info about your VPS. 您可以提供有关VPS的更多信息。 Here I will assume you have a full VPS with root access and you can control the all network access. 在这里,我假设您具有具有root用户访问权限的完整VPS,并且可以控制所有网络访问。 Apache Tomcat runs by default on port 8080. Effectively you have two options 默认情况下,Apache Tomcat在端口8080上运行。实际上,您有两个选择

  1. Run the Tomcat on the port 80 as root ( I don't recommend this approach) 以root身份在端口80上运行Tomcat(我不推荐这种方法)
  2. As @Kayaman mentiomed, install an http proxy (apache httpd, nginx,..) which would listen on port 80 and forward all requests to 8080 (search for reverse proxy) 如@Kayaman所述,安装一个http代理(Apache httpd,nginx等),该代理将侦听端口80并将所有请求转发到8080(搜索反向代理)。

Have fun 玩得开心

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM