I recently migrated my wordpress installation to docker. I'm using a nginx (in a container) as a reverse proxy to handle all incoming traffic to multiple containers on my domain. Most things work fine, however when posting a comment on wordpress the user gets a 504 Gateway Time out when hitting 'send', although the comment correctly appears on the site after that. So I suppose it's an issue with the nginx reverse proxy redirects. I have tried so many stuff I've read online, nothing seems to work for me, so I'd really appreciate some help.
I also have a custom metrics endpoint to which I send HTTP POSTs with curl, and to get this working I had to alter the curl by adding -L --post301
or it wouldn't work.
official dockerhub images
nginx:1.17.5
wordpress:5.2.4-php7.1
nginx container logs:
2019/12/01 14:29:13 [error] 21#21: *3065 upstream timed out (110: Connection timed out) while reading response header from upstream, client: <my-ip>, server: <my-domain>, request: "POST /wp-comments-post.php HTTP/1.1", upstream: "http://172.18.0.11:80/wp-comments-post.php", host: "<my-domain>", referrer: "https://<my-domain>/index.php/<the-blog-post>/"
[01/Dec/2019:14:29:13 +0000] "POST /wp-comments-post.php HTTP/1.1" 504 569 "https://<my-domain>/index.php/<the-blog-post>/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
Nginx.conf:
events{}
http {
server {
listen 80;
server_name <my-domain>;
location / {
return 301 https://$server_name$request_uri;
}
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
}
server {
listen 443 ssl;
server_name <my-domain>;
location /grafana/ {
proxy_pass http://grafana:3000/;
}
location /metrics-collect/ {
proxy_pass http://metrics:8080/collect;
}
location / {
proxy_pass http://wordpress:80/;
}
ssl_certificate /etc/letsencrypt/live/<my-domain>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<my-domain>/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
The request of the commenter:
Request URL: https://<my-domain>/wp-comments-post.php
Referrer Policy: no-referrer-when-downgrade
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate, br
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 105
Content-Type: application/x-www-form-urlencoded
DNT: 1
Host: <my-domain>
Origin: https://<my-domain>
Pragma: no-cache
Referer: https://<my-domain>/index.php/<the-blog-post>/
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36