Question

How do I get nginx to serve the "www." version of domain.com?

  • Posted on October 27, 2014
  • user123Asked by user123

Hello everyone,

I downloaded a LEMP stack onto my server and I have gotten nginx to serve domain.com, but for the life of me I cannot figure out how to get nginx to serve www.domain.com.

Here is what the code looks like currently:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html;
        index index.php index.html index.htm;

        server_name domain.com www.domain.com;

        location / {
                try_files $uri $uri/ =404;
        }

What change can I make to get www.domain.com to work?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You did not setup DNS correctly. Fix the A record for www.capayan.com

This comment has been deleted