I have a domain where I have a wildcard A record to a IP (61.61.61.61) (not under my control).
Because I wanted some pages on the domain to be under my control, I thought it was easy to proxy all data through nginx. But looks like this isn't the same behaviour. Instead when I try to load the main index of the site that was displaying correctly before, it's redirecting me to another site now.
I think this is because nginx is not proxying all data or is not forwarding some headers.
I configured nginx this way
server {
server_name test.com;
root /var/www/test.com/;
index index.html index.htm index.php;
merge_slashes on;
location /landers {
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}
location / {
proxy_pass http://61.61.61.61:80;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
# edit below to fix config display
fastcgi_param SCRIPT_FILENAME /var/www/test.com$fastcgi_script_name;
}
}
The request is not reconginzed on the 3th party server, this is probably why it is redirecting me to another site on that server.
[Edit]
So to be more clear. I want the url /landers to be hosted on my machine. That's why I have a different location in nginx for that.
The rest of the requests to the test.com should go to the correct IP address (and handled by the 3th party server).
Everything was working fine when I had the IP address as an A-record. But now nginx proxies the request and I get a 301 redirect back (from the server with IP 61.61.61.61).
Normally I shouldn't get a 301 back but rather the proxied page. That's why I guess that the request to the 61.61.61.61 server is somewhat different than going directly (using A-records instead of proxying to that server). This makes me think that the proxied HTTP request is somewhat different than the not proxied version, so that the 61.61.61.61 server can't match the correct vhost on their server.
Hope this makes things a bit more clear.