Question

my www.domain.com goes to Nginx welcome page

Posted December 6, 2021 105 views
Nginx

Hello my https://domain.com is working fine but my www.domain.com is redirected to Welcome to nginx! page.
I’m using ubuntu 20.04.

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.

×
Submit an Answer
2 answers

Hi @amirShark,

I think you have some configuration problem on your nginx virtualhost.

Take a look at https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04, explain how to correctly create the server blocks in nginx.

Hope helps you,
Sergio Turpín

by Justin Ellingwood
When using the Nginx web server, server blocks (similar to the virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain off of a single server. In this guide, we'll discuss how to configure server blocks in Nginx on an Ubuntu 16.04 server.

Hi @amirShark,

This means you haven’t configured your www domain in your Nginx config. In your Nginx domain config you’ll need to add the www part as well.

sudo nano /etc/nginx/sites-available/your_domain

The config would look something like:

server {
        listen 80;
        listen [::]:80;

        root /var/www/your_domain/html;
        index index.html index.htm index.nginx-debian.html;

        server_name your_domain.com www.your_domain;

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

Find the servername directive and include www.yourdomain on the line.