Redirect nginx

If you want to make sure all traffic only uses your preferred domain name you can create a new server {} block that redirects to the preferred domain name.

On your nginx node select config and edit the nginx.conf file.
In this example we'll redirect to https://my-domain.tld

server {
    listen 80 default_server;
    return 301 https://my-domain.tld/$request_uri;
Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request


1 comment
  • I was not able make to work. I edited the nginx.conf file and added the server directive to the end of file.

    I got the error message saying that "server" directive is not allowed there.

    Comment actions Permalink

Please sign in to leave a comment.