2

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.

EDIT

All,

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.

EDIT

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

1

3 Answers 3

6

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.

1
  • 1
    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 ^^ Mar 26, 2010 at 16:31
1

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.

1

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

Less operations - less points of refusal

2
  • How do I do that? I can not bind it to a same port. Mar 26, 2010 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 127.0.0.1:80 Of course, after that you need proxy_pass то apache socket
    – Lanselot
    Mar 30, 2010 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .