I'm running on the same server Apache (port 81) and NGINX (port 80). For www.example.com I have the below in the NGINX config file.
The problem is when Apache is started on this server ALL requests for www.example.com are going to the Apache server on port 81. This is not configured in the upstream and www.example.com is also not configured in the local Apache instance so errors all over.
I do not want this to go local but only external as defined in the upstream.
When i stop apache the upstream is used and the request from nginx are going to the servers defined in the upstream, when i start Apache again all requests are routed local to Apache
So how can i avoid the requests going to Apache when it's loaded and let nginx always use the defined upstream?
upstream mainserver {
server w1.externalserver.nl;
server w2.externalserver.nl;
}
server {
listen 80;
server_name www.example.com;
location / {
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-Forwarded-Proto $scheme;
proxy_pass http://mainserver;
}
}