可以将zuul配置为侦听端口80 [英] Can zuul be configured to listening to port 80
问题描述
Jhipster微服务,生成带有角度的jhipster网关,将网关端口设置为80,并以非root用户身份运行,存在套接字,权限被拒绝"异常,请检查文档,注意zuul也是反向代理,这是我的问题:
Jhipster microservices, generate jhipster gateway with angular, set gateway port as 80, and run as a non-root user, there is a "socket, permission denied" exception, check the docs, notice that zuul is also a reverse proxy, here is my question:
zuul是否可以配置为像nginx一样侦听80端口,如果没有,可以在jhipster网关之前添加nginx来服务网站主页吗?
Can zuul is configured to listening 80 port like nginx, if no, is it ok to add nginx before jhipster gateway to serve the website main page?
================================================ ================== 为网关设置端口80时附加异常:
================================================================= attach exception when set port 80 for gateway:
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)
推荐答案
tl; dr
对于Linux OS
tl;dr
For Linux OS
- 将服务器端口更改为大于1024的任何端口,例如8080
-
sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
- change server port to any higher than 1024, for instance 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
On linux ports below 1024 can be opened only by root, so the port 80 is restricted by default
More info, with similar answers https://stackoverflow.com/a/33704078/9183844
这篇关于可以将zuul配置为侦听端口80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!