About Apache HTTP forwarding backend application get front port problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.