-1

I am using httpd server for load balancing and as web server. I want to convert my request from : http://hostname:port/service to http://hostname/service How it can be done using RewriteRule or any other technique ?

  • 1
    Please add your attempts and any issue or error you encountered trying to solve your problem. – S19N Jun 21 at 0:18
1

The :port comes from the URI scheme (RFC 3986, 3) Syntax Components:

     foo://example.com:8042/over/there?name=ferret#nose
     \_/   \______________/\_________/ \_________/ \__/
      |           |            |            |        |
   scheme     authority       path        query   fragment

3.2.3. Port

The port subcomponent of authority is designated by an optional port number in decimal following the host and delimited from it by a single colon (:) character.

  port        = *DIGIT

A scheme may define a default port. For example, the http scheme defines a default port of 80, corresponding to its reserved TCP port number. The type of port designated by the port number (e.g., TCP, UDP, SCTP) is defined by the URI scheme. URI producers and normalizers should omit the port component and its ":" delimiter if port is empty or if its value would be the same as that of the scheme's default.

Therefore,

  • http://example.com equals ONLY http://example.com:80
  • https://example.com equals ONLY https://example.com:443
  • for any other port the port is visible in the URL.

If you have a web service e.g. on http://example.com:8080/service and you would like to use a different web server (e.g. as a load balancer) on http://example.com/service, you'd need a reverse proxy on the web server listening on port 80. In Apache it's done with module mod_proxy:

<Location "/service">
  ProxyPass "http://example.com:8080/service"
</Location>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.