Redirecting from port 80 to different ports based

2019-02-02 14:54发布

问题:

I have two applications, (Atlassian JIRA and Confluence,) listening on ports 8080 and 8090, accessible through example.com:8080/jira and example.com:8090/confluence. I would like to set up a redirection on port 80 such that I can access the services through example.com/jira and example.com/confluence.

Is there a simple way to achieve this?

回答1:

There are 2 ways of solving this.

Redirect Method

  1. You seem pretty savvy setting up servers. You will need a web Server running on port 80. (Apache: Windows/*nix; IIS: Windows)
  2. Set up a virtual site / folder if you just want example.com/jira and example.com/confluence. You could also do jira.example.com and confluence.example.com if you had your DNS records pointing to the host.
  3. Use a 302 Redirect (temporary/found) to redirect a browser hitting this URL/Virtual Host to the new URL. This method changes the URL in the browser so the browser actually shows the 8080 and 8090 ports.

Proxy Method

The other way, if you wanted transparent URLs would be to set up reverse proxies on the 2 URLs. This way the proxy server on port 80 responds to the client as if the content is originating from port 80. The web server fetches the pages in the background and serves them up. You have the added benefit of caching content using a reverse proxy.