I have nginx setup as the defacto port 80
. I want to setup django+mod_wsgi on Apache2. I'm worried if I leave Apache2 as 80
it will cause a conflict.
Is it better to avoid the headache and change Apache to a different port?
server {
listen 80;
server_name work.domain.org;
access_log /www/work.domain.org/log/access.log;
error_log /www/work.domain.org/log/error.log;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Magic-Header "secret";
client_max_body_size 10m;
}
}
In general you want the reverse proxy to listen on the port clients will be connecting to. So in this case you want nginx to be on port 80. The Apache port really doesn't mater, it could be port 80 as long as the port is not no use on the same server with the same IP.
So if your reverse proxy machine doesn't run Apache as well, they both could have been 80. You could also have a secondary IP on the host and have Apache bind to that IP/Port pair and have both nginx and Apache listen on port 80 on the same machine (just different IPs).
For example (nc listens on a specified IP and port):
Think I kind of answered my own question in that:
Can't bind to the same port, therefore I have to choose another. I could've sworn though someone had mentioned set both to port 80, guess I misread.
You can bind them to both the same port, but on different interfaces. For example, you can bind your front-end to your external IP on port 80 and bind the back-end to your localhost on port 80.