Question

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 http://whatjackhasmade.co.uk and https://noface.co.uk.

https://noface.co.uk is unaccessible until I go to https://noface.co.uk/wp-admin and login to my account.

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

# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name noface.co.uk www.noface.co.uk;
        return 301 https://$server_name$request_uri;
}

server {

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

        root /var/www/noface.co.uk/html/wordpress;

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

        server_name noface.co.uk www.noface.co.uk;

        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.

Subscribe
Share

Something you might have overseen, did you check in the wordpress settings at general? There you can edit the site link (http/https).

@CrypticDesigns I’ve posted the log; I apologise in advance as I am no expert when it comes to debugging the Nginx log.

I’ve also updated the try_files, and the problem still exists. :/

Stack trace:
#0 /var/www/whatjackhasmade.co.uk/html/wordpress/wp-content/plugins/amp/includes/class-amp-content.php(98): AMP_DOM_Utils::get_dom_from_content('<p><a href="htt...')
#1 /var/www/whatjackhasmade.co.uk/html/wordpress/wp-content/plugins/amp/includes/class-amp-content.php(85): AMP_Content_Sanitizer::sanitize('<p><a href="htt...', Array, Array)
#2 /var/www/whatjackhasmade.co.uk/html/wordpress/wp-content/plugins/amp/includes/class-amp-content.php(46): AMP_Content->sanitize('<p><a href="htt...')
#3 /var/www/whatjackhasmade.co.uk/html/wordpress/wp-content/plugins/amp/includes/class-amp-content.php(22): AMP_Content->transform()
#4 /var/www/whatjackhasmade.co.uk/html/wordpress/wp-content/plugins/amp/includes/class-amp-post-template.php(242): AMP_Content->__construct('<a href="http:/...', Array, Array, Array)
#5 /var" while reading response header from upstream, client: 66.249.64.222, server: whatjackhasmade.co.uk, request: "GET /vintage-ensembles-vintage-clothing-store/amp/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.whatjackhasmade.co.uk"
2017/06/25 14:44:13 [error] 32010#32010: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-content/plugins/w3-total-cache/Config.php on line 117
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0" while reading response header from upstream, client: 82.1.145.76, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.noface.co.uk"
2017/06/25 14:44:45 [error] 32010#32010: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-content/plugins/w3-total-cache/ObjectCache_WpObjectCache_Regular.php on line 675
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0" while reading response header from upstream, client: 82.1.145.76, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.noface.co.uk"
2017/06/25 14:45:55 [error] 32010#32010: *11 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/wp-db.php on line 1300
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/plugin.php on line 449" while reading response header from upstream, client: 82.1.145.76, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk", referrer: "http://m.facebook.com/"
2017/06/25 14:49:42 [error] 32010#32010: *33 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 64.41.200.101, server: noface.co.uk, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk"
2017/06/25 14:49:47 [error] 32010#32010: *39 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-content/plugins/w3-total-cache/Config.php on line 117
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0" while reading response header from upstream, client: 80.56.66.203, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk", referrer: "https://www.digitalocean.com/community/questions/502-nginx-issue-website-not-showing-unless-logged-in-to-wordpress"
2017/06/25 14:50:47 [crit] 32010#32010: *159 SSL_do_handshake() failed (SSL: error:14094085:SSL routines:ssl3_read_bytes:ccs received early) while SSL handshaking, client: 64.41.200.101, server: 0.0.0.0:443
2017/06/25 14:50:48 [crit] 32010#32010: *160 SSL_do_handshake() failed (SSL: error:14094085:SSL routines:ssl3_read_bytes:ccs received early) while SSL handshaking, client: 64.41.200.101, server: 0.0.0.0:443
2017/06/25 15:09:47 [error] 32010#32010: *249 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/wp-db.php on line 1300
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/plugin.php on line 449" while reading response header from upstream, client: 148.251.15.150, server: noface.co.uk, request: "GET /robots.txt HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk"
2017/06/25 15:15:47 [error] 32010#32010: *254 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-content/plugins/w3-total-cache/ObjectCache_WpObjectCache_Regular.php on line 675
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0" while reading response header from upstream, client: 186.151.96.200, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk"
2017/06/25 15:16:18 [error] 32010#32010: *254 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/option.php on line 1103
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0" while reading response header from upstream, client: 186.151.96.200, server: noface.co.uk, request: "GET /admin HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk"
2017/06/25 15:16:29 [error] 32010#32010: *268 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-content/plugins/w3-total-cache/ObjectCache_WpObjectCache.php on line 36
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/load.php on line 677" while reading response header from upstream, client: 186.151.96.200, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk"
2017/06/25 16:00:21 [error] 32010#32010: *336 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/pluggable.php on line 2069
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/load.php on line 677" while reading response header from upstream, client: 82.1.145.76, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk", referrer: "https://l.facebook.com/"
2017/06/25 16:03:48 [error] 355#355: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/noface.co.uk/html/wordpress/wp-includes/pluggable.php on line 2018
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0" while reading response header from upstream, client: 82.1.145.76, server: noface.co.uk, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "noface.co.uk", referrer: "https://l.facebook.com/"

Check the error logs and see what you can find there. If you don’t know what it says, post it here please. Maybe try to use try_files $uri $uri/ /index.php?$args; inside location /

I had a look at the general settings, and the site link did need updating. However, Nginx still returns a 302 error, or my website returns a 500 HTTP Error.


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

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.

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;