Hi,

Having some trouble getting a 2nd nginx block live - can’t get the domain to point to the correct root folder and the Let’s Encrypt Acme challenge is failing (probably related problems).

The server is Ubuntu 18.04 and I’m using it as a sandbox to work on sites.

Here is the sites available conf for the site that is just redirecting to the nginx default page

server {
        root /var/www/boothslop.online;
        index index.php index.html index.htm index.nginx-debian.html
        server_name boothslop.online www.boothslop.online;
location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }
        location / {
     #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}

Here is the sites available conf for the site that is working correctly both for lets encrypt and finding the correct root folder when the domain is accessed.

server {
        root /var/www/webtest.tech;
        index index.php index.html index.htm index.nginx-debian.html
        server_name webtest.tech www.webtest.tech;
location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }
        location / {
     #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/webtest.tech/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/webtest.tech/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = www.webtest.tech) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = webtest.tech) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        server_name webtest.tech www.webtest.tech;

}

Thanks very much in advance!

edited by bobbyiliev

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.

×
1 answer

Hello,

You need to make sure that the Nginx user has permissions to the /var/www/boothslop.online folder. You could do that with:

chown -R www-data:www-data /var/www/boothslop.online

If this does not help, make sure that your second config is enabled:

ls -l /etc/nginx/sites-enabled/

If you don’t see the new config there, make sure to create a symlink.

If the above are true, then check your error log for more information:

tail -100 /var/log/nginx/error.log

Regards,
Bobby

Submit an Answer