1

I want to redirect to 444 when someone uses the IP address. Most online says to use the underscore to catch all but I currently have a block that uses that to redirect http to https:

 listen 80; listen 443 ssl; server_name _; ssl_certificate /etc/ssl/nginx.crt; ssl_certificate_key /etc/ssl/nginx.key; return 301 https://$host$request_uri; } 

What's the best way to include both without having to use a If statement?

2
  • There are two ways to go about this, it can be specified in a server block (what you've given), or you can use a location directive. Commented Jan 31, 2020 at 0:25
  • The underscore is deprecated and effectively does nothing. You are looking for default_server on the listen directive. See this document. Commented Jan 31, 2020 at 8:26

1 Answer 1

1

Why not use the solution with an if-statement?

 if ($http_host != "example.com") { return 444; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.