Under the Apache+jetty forwarding configuration, the jetty application gets Request.getserverport () to the port of jetty, not the port of the Apache portal, as in the case of:
Apache by configuring a virtual host:
<virtualhost *:80> ServerName "admin.test.com" proxyrequests Off proxypass/http://localhost : 6808/ proxypassreverse/http://localhost:6808/ </VirtualHost>
Accept external access on port 80 and forward to Port 6808.
However, when an app on port 6808 Gets the Request.getserverport () to 6808, not 80, there are some problems when constructing a self-referencing address:
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport ()
This code generally refers to the front-end JSP page or the program needs to make a URL address reference. The application port is not correct at this time.
General Solutions:
1, modify the BasePath access mode, to the configuration file mode, directly read the configuration file, but this method is not particularly convenient, not recommended to use
2. Using reverse proxy server configuration
- Nginx Configuration Method
Proxy_set_header host $host: $port
- Apache Configuration Method
<virtualhost *:80> ServerName "admin.test.com" proxyrequests Off proxypass/http://localhost : 6808/ proxypassreverse/http://localhost:6808/ proxypreservehost on</virtualhost>
About Apache HTTP forwarding backend application get front port problem