Quantcast
Viewing latest article 1
Browse Latest Browse All 3

Answer by Linztm for nginx 302 redirect only naked IP

You would need to have a single server block as both will not be read while they match the same listen directive.

You should be able to modify the blocks as follows to acheive your desired results:

server {   listen 80;   server_name 198.251.86.133;   return 302 http://www.jacobdevans.com/anycast-301/;}server {   listen 80 default_server;   return 302 http://www.$host$request_uri;}

Setting the default_server and allowing that block to be the 'catch all' while explicitly defining the IP to match the incoming HOST header will result in all requests for the direct IP being redirected to http://www.jacobdevans.com/anycast-301/ and the rest to http://www.$host$request_uri.


Viewing latest article 1
Browse Latest Browse All 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>