502 Nginx Issue - Website not showing unless logged in to WordPress

I have recently added a 2nd domain to a single Ubuntu 16.04 server and created the necessary files for use with Nginx. This allows Nginx to point to both directory paths for the corresponding domains.

I currently have and is unaccessible until I go to and login to my account.

Here is the following sites-available file for, the sites-enabled is a symlink to this file.

# Default server configuration
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        return 301 https://$server_name$request_uri;

server {

        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        include snippets/;
        include snippets/ssl-params.conf;

        root /var/www/;

        index index.php index.html index.htm index.nginx-debian.html;


        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                fastcgi_pass unix:/run/php/php7.0-fpm.sock;

        location ~ /.well-known {
                allow all;

The issue has only recently occured since I have enabled https:// with an SSL certificate. The https:// works but only when accessing wp/admin. Any help would be greatly appreciated.

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Thanks, @hansen turns out WP Total Cache plugin was the issue, I’ll do some research into using an alternative plugin.

Thank you for the compliment on the logo, speed is one of my main focuses with websites, I aim for a 1 second load speed or as close as I can get :)

Hi @jacknoface

I don’t see any error, when going to the site - only a blank page. So you need to check the error log for further details. Try running this command to get the last 30 lines:

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

And like @CrypticDesigns says, the try_files isn’t correct for WordPress. Should be:

try_files $uri $uri/ /index.php?$args;