Report this

What is the reason for this report?

wp-comments-post.php returns 504 on nginx

Posted on June 11, 2017
agm

By agm

Setup a fresh droplet on Ubunut 16.04 and installed a basic LEMP stack with mariadb, php7, nginx. Installed wordpress to /var/www/mydomain.com/ using wp-cli. Created a basic new nginx configuration in /etc/nginx/sites-available/mydomain.com.

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

        root /var/www/mydomain.com;
        index index.php;

        server_name mydomain.com;

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

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

When I use the website, it works perfectly except when I try to post a comment, it hangs for over a minute before nginx returns a 504 gateway time-out. However — comment is received.

This problem disappears when I set server_name _; and use this site as the default_server.

Tried php 7.1, wordpress 4.7, wordpress 4.8, ppa:nginx/stable package, etc, with no success.

Anyone else seen this problem? Cheers!



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!

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.

Hi @agm

Your try_files for WordPress should look like this:

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

Hey I’m having this exact issue (saw your SE post as well; identical logs / lackthereof on my end) – did you ever end up solving it??

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.