S. A.
S. A.

Reputation: 111

Nginx adding new site's subdomain takes no effect

I have a VPS on digitalocean that works great with five subdomains. But when I decided to add 6th (RC), it doesn't work. In order not to make mistakes, I made the following:

  1. duplicated existing (working) /var/www folder and renamed into rc
  2. changed rights to this folder sudo chmod -R www-data:www-data rc
  3. duplicated working config in etc/nginx/sites-available and renamed it to rc
  4. changed server_name and root rooting there. So, it looks like so:
server {
        listen 80;
        listen [::]:80;
        charset UTF-8;

        server_name rc.myserver.com;
        root /var/www/rc;
        index index.html;

        location ~ /\. {
        deny all;
        }

        location / {
            try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        }
    }
  1. created symlink with ln -s /etc/nginx/sites-available/rc /etc/nginx/sites-enabled/rc
  2. restarted nginx: sudo service nginx restart

Now my /etc/nginx/sites-enabled/ folder looks so:

lrwxrwxrwx 1 root root   31 Jul 21  2019 html -> /etc/nginx/sites-available/html
lrwxrwxrwx 1 root root   31 Jul 19  2019 hunt -> /etc/nginx/sites-available/hunt
lrwxrwxrwx 1 root root   32 Dec  2 16:43 monit -> /etc/nginx/sites-available/monit
lrwxrwxrwx 1 root root   29 Feb  1 13:57 rc -> /etc/nginx/sites-available/rc
lrwxrwxrwx 1 root root   31 Jul 21  2019 rent -> /etc/nginx/sites-available/rent
lrwxrwxrwx 1 root root   32 Jul 20  2019 tools -> /etc/nginx/sites-available/tools

sudo netstat -plutn | grep nginx shows:

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      29155/nginx: master 
tcp6       0      0 :::80                   :::*                    LISTEN      29155/nginx: master 

My nginx.conf has this code lines active:

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

/var/log/nginx/error.log and /var/log/nginx/access.log didn't show any problems.

But when I try to get rc.myserver.com - I get "Failed to open the page" safari message: Safari can’t open the page “http://rc.myserver.com” because Safari can’t find the server “rc.myserver.com.”

What's the problem can be with?

Upvotes: 1

Views: 1140

Answers (1)

Ganesh Pandey
Ganesh Pandey

Reputation: 5276

Did you point your subdomain to the Droplet ip-address ?

first thing you've to do is to point your subdomains to the single ip address via your DNS provider (A, CNAME).

I think that's why you are getting error:

Safari can’t open the page “http://rc.myserver.com” because Safari can’t find the server “rc.myserver.com”.

enter image description here

point rc.yourserver.com to Droplet IP address :)

Upvotes: 1

Related Questions