java - 无法在 Google Compute Engine 中使用 80 端口启动 tomcat

标签 java tomcat google-cloud-platform google-compute-engine centos7

我在 CentOS7 和 Tomcat 8 上使用了 Google Compute Engine 实例。Tomcat 服务器在端口 8080 上工作正常,但是当我将端口更改为 80 时发生套接字异常。 Tomcat 异常(exception)是,

org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-80]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)
        at org.apache.catalina.core.StandardService.initInternal(StandardService.java:552)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:875)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:632)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:655)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:309)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:995)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
        ... 12 more
Caused by: java.net.SocketException: Permission denied
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:219)
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1087)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:265)
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:581)
        at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:68)
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:993)

我的防火墙角色, enter image description here

我已经关注了 Google cloud Compute Engine refuse outer access through apache2 但没有作品..请指教.......

最佳答案

如前所述here通过@gdahlm,

linux/Unix 上低于 1024 的端口是“特权端口”,需要提升权限才能创建。

在 GCP(谷歌云平台)中,您有多种选择。

作为非特权用户使用 1024 以上的高端口并且:

  • 连接到你 url 中的高端口 https://foo:8443
  • 使用 GCP 网络或 HTTP/HTTPS 负载均衡器将端口 443 转发到高 港口
  • 利用 IP 表将数据包从 443 转发到高端口 在虚拟机实例中
  • 使用 suid、sudo 或其他方式运行服务 方法
  • 授予 _CAP_NET_BIND_SERVICE_ capabilities(7) 给 过程。

最后两个选项具有复杂的安全隐患 并且应该尽可能避免。

关于java - 无法在 Google Compute Engine 中使用 80 端口启动 tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52258329/

相关文章:

python - 将 ndarray(OpenCV 中的图像)作为 .jpg 或 .png 上传到谷歌云存储

tensorflow - 如何在谷歌计算引擎上运行 tensorflow GPU 容器?

java - 如何在Java中暂停/重新启动SingleThreadExecutor(ExecutorService)?

java - 我可以在 for 和 switch 语句之外声明和初始化 ImageView 并在其中设置其属性吗?

java - 如果调整父 JFrame 的大小,如何调整 JButton 的位置?

apache - 使用 .htaccess 的 URL 重定向

java - 使用 JAXB XMLStreamReader 防止 XXE 攻击

java - 如何隐藏TOMCAT webapp文件夹中的JSP文件

tomcat - StandardWrapperValve 是否创建新的 servlet 实例?

amazon-web-services - 将 Prometheus 运算符与 k8s 的 DB 卷一起使用