可以将zuul配置为侦听端口80

时间:2018-10-04 02:31:10

标签: jhipster

Jhipster微服务,生成带有角度的jhipster网关,将网关端口设置为80,并以非root用户身份运行,存在“套接字,权限被拒绝”异常,请检查文档,注意zuul也是反向代理,这是我的问题:

zuul是否可以配置为像nginx一样侦听80端口,如果没有,可以在jhipster网关之前添加nginx来服务网站主页吗?

================================================ ================== 设置网关的端口80时附加异常:

org.springframework.boot.web.server.WebServerException: Unable to start embedded Undertow
 at org.springframework.boot.web.embedded.undertow.UndertowServletWebServer.start(UndertowServletWebServer.java:162)
 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:300)
 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)
 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
 at com.james.gateway.HdGatewayApp.main(HdGatewayApp.java:66)
 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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
 at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58)
Caused by: java.lang.RuntimeException: java.net.SocketException: Permission denied
 at io.undertow.Undertow.start(Undertow.java:249)
 at org.springframework.boot.web.embedded.undertow.UndertowServletWebServer.start(UndertowServletWebServer.java:145)
 ... 16 common frames omitted
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.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:190)
 at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:243)
 at io.undertow.Undertow.start(Undertow.java:192)

1 个答案:

答案 0 :(得分:0)

tl; dr
对于Linux OS

  • 将服务器端口更改为大于1024的任何端口,例如8080
  • sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080

在低于1024的Linux端口上,只能由root用户打开,因此默认情况下,端口80是受限的
更多信息,并提供相似的答案https://stackoverflow.com/a/33704078/9183844