Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

HI all,

I am currently using nginx as front-end proxy for Apache. I have setup nginx to use port 80 and Apache to use 8080. But after nginx redirected the request to Apache, the port 8080 is visible from the browser. Is there any way this port can be hidden and not visible because it would be very ugly for users that wants to bookmark it.



It looks like the request goes to Apache directly without going to nginx first. Is there any way I can find out why is that so and how to make the request goes to nginx first?

THanks in advance for your help.


So I restarted the whole server to load the configuration and make sure that nginx is loaded first instead of Apache.

share|improve this question
I answered a similar question with common solutions here:… – Warner Mar 26 '10 at 15:28
up vote 7 down vote accepted

Use nginx's proxy_pass directive instead of redirecting. This way, nginx will request the data from Apache but send it to the browser itself from port 80. This is known as a "reverse proxy", and here's a tutorial on setting it up for Ubuntu.

share|improve this answer
Good Answer! UP! – Jimmy Mar 26 '10 at 15:42
Also many corporate networks only allow a few outbound ports like 80 and 443 - running a site on 8080 might make it unaccessible to a good number of people ^^ – Oskar Duveborn Mar 26 '10 at 16:31

I don't think you can hide that information from the user/browser but if (and I am assuming this is the case) nginx and apache are not on the same host you could redirect port 80 to port 8080 on the apache system .. users will not notice anything but google will notice the redirect when it caches/crawls your website and might give up on caching/crawling it.
For redirect use Iptables like so:

/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j \
REDIRECT --to-port 8080

It might need adaptation.

share|improve this answer

In my opinion it's better bind nginx on external_ip:80 and apache on, and no need to hide something

Less operations - less points of refusal

share|improve this answer
How do I do that? I can not bind it to a same port. – Joshua Partogi Mar 26 '10 at 23:23
you are bind app to a socket, not a port. socket is an ip:port We are use this on many servers. you must specify Listen directive on exact socket nginx: listen external_ip; apache: Listen Of course, after that you need proxy_pass то apache socket – Lanselot Mar 30 '10 at 11:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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