I'm trying to setup a 302 redirect if someone enters the IP address, but 301 all other requests to the www.subdomain of that domain.
server { listen 198.251.86.133:80; server_name 198.251.86.133; return 302 http://www.jacobdevans.com/anycast-301/;}server { listen 198.251.86.133:80; server_name _; return 301 http://www.$host$request_uri;}
I have the 301 working, except if I put the 302 section above in, my hope is to allow anyone (non-https, sorry) to be able to point their A record root domain somewhere easy to do 301, example.com to www.example.com
Currently, everything is caught by the first listen option
# curl -I jacobdevans.comHTTP/1.1 302 Moved TemporarilyServer: nginx/1.6.3Date: Mon, 28 Sep 2015 20:08:45 GMTContent-Type: text/htmlContent-Length: 160Connection: keep-aliveLocation: http://www.jacobdevans.com/anycast-301/# curl -I 198.251.86.133HTTP/1.1 302 Moved TemporarilyServer: nginx/1.6.3Date: Mon, 28 Sep 2015 20:08:56 GMTContent-Type: text/htmlContent-Length: 160Connection: keep-aliveLocation: http://www.jacobdevans.com/anycast-301/
http://www.redirect-checker.org will pull from my luxembourg location
Thanks!