docker wordpress and nginx user permission - wordpress

Trying to setup wordpress and nginx in docker containers while sharing the volume from wordpress to nginx. While doing so, nginx is unable to read the files from the volume as the users are different. How do I solve this?
This is currently causing this error below:
wordpress_1 | 172.18.0.17 - 18/Feb/2018:15:39:27 +0000 "GET /index.php" 404
nginx_1 | 2018/02/18 15:39:27 [error] 7#7: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.18.0.1, server: galaxycard.in, request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.13:9000", host: "127.0.0.1:3000"
nginx_1 | 172.18.0.1 - - [18/Feb/2018:15:39:27 +0000] "GET / HTTP/1.1" 404 47 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"

Related

How to solve error 503 in Kubernetes NGINX Ingress

I'm trying to configure Kubernetes Dashboard using NGINX INGRESS but for some reason I'm getting a 503 error.
I'm running Kubernetes locally in my macbook with docker desktop.
First thing I did was apply/install NGINX INGRESS CONTROLLER
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.47.0/deploy/static/provider/cloud/deploy.yaml
Second step was to apply/install kubernetes dashboard YML File
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml
Third Step was to apply the ingress service
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dashboard-ingress
namespace: kubernetes-dashboard
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/configuration-snippet: |-
proxy_ssl_server_name on;
proxy_ssl_name $host;
spec:
rules:
- http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: kubernetes-dashboard
port:
number: 433
When I try to access http://localhost and/or https://localhost I get a 503 Service Temporarily Unavailable Error from nginx
Not sure what I'm doing wrong.
Here is part of the log from the NGINX POD
I0630 23:36:42.049398 10 main.go:112] "successfully validated configuration, accepting" ingress="dashboard-ingress/kubernetes-dashboard"
I0630 23:36:42.055306 10 event.go:282] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"kubernetes-dashboard", Name:"dashboard-ingress", UID:"85e7bd9e-308d-4848-8b70-4a3591415464", APIVersion:"networking.k8s.io/v1beta1", ResourceVersion:"47868", FieldPath:""}): type: 'Normal' reason: 'Sync' Scheduled for sync
I0630 23:36:42.056435 10 controller.go:146] "Configuration changes detected, backend reload required"
I0630 23:36:42.124850 10 controller.go:163] "Backend successfully reloaded"
I0630 23:36:42.125333 10 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"ingress-nginx", Name:"ingress-nginx-controller-5b74bc9868-gplcq", UID:"bbd70716-b843-403b-a8f9-2add0f63f63f", APIVersion:"v1", ResourceVersion:"46315", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
192.168.65.3 - - [30/Jun/2021:23:36:44 +0000] "GET / HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.003 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.1.0.25:8443 48 0.002 400 395aec46af3b21e79cd650f2f86722f3
2021/06/30 23:36:44 [error] 1222#1222: *17477 recv() failed (104: Connection reset by peer) while sending to client, client: 192.168.65.3, server: _, request: "GET / HTTP/1.1", upstream: "http://10.1.0.25:8443/", host: "localhost"
2021/06/30 23:36:45 [error] 1222#1222: *17512 recv() failed (104: Connection reset by peer) while sending to client, client: 192.168.65.3, server: _, request: "GET / HTTP/1.1", upstream: "http://10.1.0.25:8443/", host: "localhost"
192.168.65.3 - - [30/Jun/2021:23:36:45 +0000] "GET / HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.002 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.1.0.25:8443 48 0.001 400 a15e1e48987948cb93503b494d188654
2021/07/01 00:09:31 [error] 1224#1224: *49299 recv() failed (104: Connection reset by peer) while reading upstream, client: 192.168.65.3, server: _, request: "GET / HTTP/1.1", upstream: "http://10.1.0.25:8443/", host: "localhost"
192.168.65.3 - - [01/Jul/2021:00:09:31 +0000] "GET / HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.002 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.1.0.25:8443 48 0.001 400 ac6b88ca52b73358c39371cb4422761d
2021/07/01 00:09:32 [error] 1221#1221: *49336 recv() failed (104: Connection reset by peer) while sending to client, client: 192.168.65.3, server: _, request: "GET / HTTP/1.1", upstream: "http://10.1.0.25:8443/", host: "localhost"
192.168.65.3 - - [01/Jul/2021:00:09:32 +0000] "GET / HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.001 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.1.0.25:8443 48 0.001 400 2c5cd2d9403a8e50a77fdc897c694792
2021/07/01 00:09:33 [error] 1221#1221: *49338 recv() failed (104: Connection reset by peer) while sending to client, client: 192.168.65.3, server: _, request: "GET / HTTP/1.1", upstream: "http://10.1.0.25:8443/", host: "localhost"
192.168.65.3 - - [01/Jul/2021:00:09:33 +0000] "GET / HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.001 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.1.0.25:8443 48 0.000 400 f1f630c886d20b9b9c59bd9e0e0e3860
2021/07/01 00:09:33 [error] 1224#1224: *49344 recv() failed (104: Connection reset by peer) while reading upstream, client: 192.168.65.3, server: _, request: "GET / HTTP/1.1", upstream: "http://10.1.0.25:8443/", host: "localhost"
192.168.65.3 - - [01/Jul/2021:00:09:33 +0000] "GET / HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.001 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.1.0.25:8443 48 0.001 400 2ab6774dec6e2a89599c4745d24b9661
192.168.65.3 - - [01/Jul/2021:00:09:33 +0000] "GET / HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.001 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.1.0.25:8443 48 0.000 400 c9147e08203d9ec8e7b0d0debab8d556
2021/07/01 00:09:33 [error] 1222#1222: *49360 recv() failed (104: Connection reset by peer) while sending to client, client: 192.168.65.3, server: _, request: "GET / HTTP/1.1", upstream: "http://10.1.0.25:8443/", host: "localhost"
I0701 00:10:19.024220 10 main.go:112] "successfully validated configuration, accepting" ingress="dashboard-ingress/kubernetes-dashboard"
I0701 00:10:19.026772 10 controller.go:146] "Configuration changes detected, backend reload required"
I0701 00:10:19.027392 10 event.go:282] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"kubernetes-dashboard", Name:"dashboard-ingress", UID:"85e7bd9e-308d-4848-8b70-4a3591415464", APIVersion:"networking.k8s.io/v1beta1", ResourceVersion:"50637", FieldPath:""}): type: 'Normal' reason: 'Sync' Scheduled for sync
I0701 00:10:19.102759 10 controller.go:163] "Backend successfully reloaded"
I0701 00:10:19.103246 10 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"ingress-nginx", Name:"ingress-nginx-controller-5b74bc9868-gplcq", UID:"bbd70716-b843-403b-a8f9-2add0f63f63f", APIVersion:"v1", ResourceVersion:"46315", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
192.168.65.3 - - [01/Jul/2021:00:11:27 +0000] "GET / HTTP/1.1" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - c449f6e8082761ddc3432f956f4701f2
192.168.65.3 - - [01/Jul/2021:00:11:29 +0000] "GET / HTTP/1.1" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 657 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - 3a41974b01c5e63e734fce6e37b98e4c
192.168.65.3 - - [01/Jul/2021:00:11:56 +0000] "GET / HTTP/2.0" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 408 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - c01f7bec83d3be6b26703b8808f9922a
192.168.65.3 - - [01/Jul/2021:00:11:58 +0000] "GET / HTTP/2.0" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 24 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - dc39bcddd4ecfdefe931bf16fe3c1557
192.168.65.3 - - [01/Jul/2021:00:16:36 +0000] "GET / HTTP/1.1" 503 190 "-" "curl/7.64.1" 73 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - 82aad4321afbccb3fc54ac75d96b66ee
192.168.65.3 - - [01/Jul/2021:00:31:47 +0000] "GET / HTTP/2.0" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 417 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - c4ab3d2f272be4d38df62c0ffd50bfe9
I0701 00:48:02.059067 10 main.go:112] "successfully validated configuration, accepting" ingress="dashboard-ingress/kubernetes-dashboard"
I0701 00:48:02.062292 10 event.go:282] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"kubernetes-dashboard", Name:"dashboard-ingress", UID:"85e7bd9e-308d-4848-8b70-4a3591415464", APIVersion:"networking.k8s.io/v1beta1", ResourceVersion:"53737", FieldPath:""}): type: 'Normal' reason: 'Sync' Scheduled for sync
I0701 00:48:02.062876 10 controller.go:146] "Configuration changes detected, backend reload required"
I0701 00:48:02.131494 10 controller.go:163] "Backend successfully reloaded"
I0701 00:48:02.131787 10 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"ingress-nginx", Name:"ingress-nginx-controller-5b74bc9868-gplcq", UID:"bbd70716-b843-403b-a8f9-2add0f63f63f", APIVersion:"v1", ResourceVersion:"46315", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
192.168.65.3 - - [01/Jul/2021:00:48:12 +0000] "GET / HTTP/2.0" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 417 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - d50e3bb0db3a5fa7581c405b8c50d5c8
192.168.65.3 - - [01/Jul/2021:00:48:14 +0000] "GET / HTTP/2.0" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 15 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - c8d8752fb4d79d5bc084839ef9a767b2
I0701 00:49:50.908720 10 main.go:112] "successfully validated configuration, accepting" ingress="dashboard-ingress/kubernetes-dashboard"
I0701 00:49:50.911044 10 controller.go:146] "Configuration changes detected, backend reload required"
I0701 00:49:50.911350 10 event.go:282] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"kubernetes-dashboard", Name:"dashboard-ingress", UID:"85e7bd9e-308d-4848-8b70-4a3591415464", APIVersion:"networking.k8s.io/v1beta1", ResourceVersion:"53896", FieldPath:""}): type: 'Normal' reason: 'Sync' Scheduled for sync
I0701 00:49:50.979935 10 controller.go:163] "Backend successfully reloaded"
I0701 00:49:50.980213 10 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"ingress-nginx", Name:"ingress-nginx-controller-5b74bc9868-gplcq", UID:"bbd70716-b843-403b-a8f9-2add0f63f63f", APIVersion:"v1", ResourceVersion:"46315", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
192.168.65.3 - - [01/Jul/2021:00:50:55 +0000] "GET / HTTP/2.0" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 417 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - d62a8012bc23bbc35a47621d54d68a62
192.168.65.3 - - [01/Jul/2021:00:51:00 +0000] "GET / HTTP/2.0" 503 592 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" 15 0.000 [kubernetes-dashboard-kubernetes-dashboard-433] [] - - - - 0cbfd2274ad687fc1aaff76dbc483659
Here is the log for the Kubernete Dashboard Pod
kubectl logs kubernetes-dashboard-78c79f97b4-w5pw9 -n kubernetes-dashboard  ✔  docker-desktop ⎈
2021/06/30 23:01:40 Starting overwatch
2021/06/30 23:01:40 Using namespace: kubernetes-dashboard
2021/06/30 23:01:40 Using in-cluster config to connect to apiserver
2021/06/30 23:01:40 Using secret token for csrf signing
2021/06/30 23:01:40 Initializing csrf token from kubernetes-dashboard-csrf secret
2021/06/30 23:01:40 Empty token. Generating and storing in a secret kubernetes-dashboard-csrf
2021/06/30 23:01:40 Successful initial request to the apiserver, version: v1.21.1
2021/06/30 23:01:40 Generating JWE encryption key
2021/06/30 23:01:40 New synchronizer has been registered: kubernetes-dashboard-key-holder-kubernetes-dashboard. Starting
2021/06/30 23:01:40 Starting secret synchronizer for kubernetes-dashboard-key-holder in namespace kubernetes-dashboard
2021/06/30 23:01:41 Initializing JWE encryption key from synchronized object
2021/06/30 23:01:41 Creating in-cluster Sidecar client
2021/06/30 23:01:41 Auto-generating certificates
2021/06/30 23:01:41 Successful request to sidecar
2021/06/30 23:01:41 Successfully created certificates
2021/06/30 23:01:41 Serving securely on HTTPS port: 8443
Here are the endpoints for the kubernetes-dashboard namespace
kubectl get ep -n kubernetes-dashboard
NAME ENDPOINTS AGE
dashboard-metrics-scraper 10.1.0.24:8000 11h
kubernetes-dashboard 10.1.0.25:8443 11h
Any help would be greatly appreciated.
I was able to fix this issue.
In my ingress ymal file I had a typo. Port number was set to 433 instead of 443
As soon as I made and applied that change, I was able to access the dashboard login page with: https://localhost and http://localhost

Nice URLs in meidawiki and nginx gives error: FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

so I set up Mediawiki on a server and it worked nice. Now I wanted to change the virtual server config of nginx so I have nice urls. I followed this doc: https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx
Here are my settings:
Working conf: https://paste.ngx.cc/ab
Not working conf (nice urls):
Virtual Server: https://paste.ngx.cc/1436
LocalSettings.php has added:
$wgScriptPath = "/mediawiki";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
The wiki is installed at /var/www/my-site.com/mediawiki
The error is:
FastCGI sent in stderr: "Primary script unknown" while reading
response header from upstream, client: xxx.xxx.xxx.xxx, server:
my-site.ch, request: "GET /wiki/Main_page HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host:
"www.my-site.com"
Entry from access log:
"GET
/load.php?debug=false&lang=en&modules=ext.uls.webfonts.fonts%2Crepository%7Cjquery.webfonts&skin=timeless&version=1ejfn7l
HTTP/1.1" 200 19908 "http://www.my-site.ch/index.php?title=Main_Page"
"Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
Any idea what exactly is going on?

Nginx "502 Bad Gateway" after I recover my vps from a former snapshot and relocate to anther IP

As the title, I use nginx/hhvm/wordpress to run my blog. At first, I guessed there was some hard-coding in some config files. But I have checked every config files, there is no hard-coding at all. So what happened?
I did check CPU and memory:
root#vultr:~# mcm
total used free shared buffers cached
Mem: 993 853 140 4 405 118
-/+ buffers/cache: 330 663
Swap: 0 0 0
--sort=-pcpu
PID %CPU RSS STIME TIME CMD
25179 0.6 3568 07:21 00:00:00 -bash
25160 0.5 4300 07:21 00:00:00 sshd: root#pts/4
1 0.0 1708 Jul23 00:00:04 /sbin/init
2 0.0 0 Jul23 00:00:00 [kthreadd]
3 0.0 0 Jul23 00:00:01 [ksoftirqd/0]
--sort=-rss
PID %CPU RSS STIME TIME CMD
1534 0.0 83552 Jul23 00:20:27 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql
2040 0.0 10768 Jul23 00:07:52 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
2313 0.0 8048 Jul23 00:18:51 /usr/bin/python /usr/bin/fail2ban-server -b -s /var/run/fail2ban/fail2ban.sock -p /var/run/fail2ban/fail
893 0.0 5836 Jul23 00:00:19 rsyslogd
25091 0.0 4304 07:14 00:00:00 sshd: root#pts/3
And nginx log:
root#vultr:~# tail /var/log/nginx/access.log.1
103.205.63.137 - - [16/Aug/2017:07:07:40 +0000] "POST /wp-login.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
103.205.63.137 - - [16/Aug/2017:07:07:41 +0000] "GET /wp-login.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
103.205.63.137 - - [16/Aug/2017:07:07:41 +0000] "POST /wp-login.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
106.121.66.175 - - [16/Aug/2017:07:10:36 +0000] "GET /favicon.ico HTTP/1.1" 502 172 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0"
180.191.111.155 - - [16/Aug/2017:07:10:52 +0000] "POST /xmlrpc.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
180.191.111.155 - - [16/Aug/2017:07:10:53 +0000] "GET /wp-login.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
180.191.111.155 - - [16/Aug/2017:07:10:53 +0000] "POST /wp-login.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
180.191.111.155 - - [16/Aug/2017:07:10:53 +0000] "GET /wp-login.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
180.191.111.155 - - [16/Aug/2017:07:10:53 +0000] "POST /wp-login.php HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
176.31.64.186 - - [16/Aug/2017:07:12:06 +0000] "GET /2015/11/07/hello-world/ HTTP/1.1" 502 172 "-" "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
root#vultr:~# tail /var/log/nginx/error.log.1
2017/08/16 07:07:40 [error] 3725#0: *38564 connect() failed (111: Connection refused) while connecting to upstream, client: 103.205.63.137, server: silent.computer, request: "POST /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:07:41 [error] 3725#0: *38564 connect() failed (111: Connection refused) while connecting to upstream, client: 103.205.63.137, server: silent.computer, request: "GET /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:07:41 [error] 3725#0: *38564 connect() failed (111: Connection refused) while connecting to upstream, client: 103.205.63.137, server: silent.computer, request: "POST /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:10:36 [error] 3725#0: *38570 connect() failed (111: Connection refused) while connecting to upstream, client: 106.121.66.175, server: silent.computer, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "silent.computer"
2017/08/16 07:10:52 [error] 3725#0: *38572 connect() failed (111: Connection refused) while connecting to upstream, client: 180.191.111.155, server: silent.computer, request: "POST /xmlrpc.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:10:53 [error] 3725#0: *38572 connect() failed (111: Connection refused) while connecting to upstream, client: 180.191.111.155, server: silent.computer, request: "GET /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:10:53 [error] 3725#0: *38572 connect() failed (111: Connection refused) while connecting to upstream, client: 180.191.111.155, server: silent.computer, request: "POST /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:10:53 [error] 3725#0: *38572 connect() failed (111: Connection refused) while connecting to upstream, client: 180.191.111.155, server: silent.computer, request: "GET /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:10:53 [error] 3725#0: *38572 connect() failed (111: Connection refused) while connecting to upstream, client: 180.191.111.155, server: silent.computer, request: "POST /wp-login.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "dominikasite.com"
2017/08/16 07:12:06 [error] 3725#0: *38578 connect() failed (111: Connection refused) while connecting to upstream, client: 176.31.64.186, server: silent.computer, request: "GET /2015/11/07/hello-world/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "silent.computer"
Am I getting DDOS attack? I don't know what is dominikasite.com, and it seems like someone keeps trying to login my wordpress...

Nginx proxy (jwilder/nginx-proxy) Connection reset by peer (502 Bad Gateway)

I have simple docker-compose.yml where I would like to be able to use nginx as a proxy to the containers. For now I have two containers admin and api which later on I want to make talking to each other.
Right now with configuration presented below, when I try to access api.host.dev I'm getting this:
nginx-proxy | nginx.1 | 2017/04/19 15:18:35 [error] 26#26: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.60.1, server: api.host.dev, request: "GET / HTTP/1.1", upstream: "http://172.18.0.4:9000/", host: "api.host.dev"
nginx-proxy | nginx.1 | api.host.dev 192.168.60.1 - - [19/Apr/2017:15:18:35 +0000] "GET / HTTP/1.1" 502 576 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
Right now I'm kind of out of ideas. Here is all configuration:
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
admin:
container_name: admin
image: php:7.1-fpm
restart: on-failure
volumes:
- ../admin:/var/www/admin
working_dir: /var/www
env_file:
- ./variables/dev-admin.env
api:
container_name: api
image: php:7.1-fpm
restart: on-failure
volumes:
- ../api:/var/www/api
working_dir: /var/www
env_file:
- ./variables/dev-api.env
Content of *.env files:
dev-api.env:
APP_ENV=DEV
VIRTUAL_HOST=api.host.dev
VIRTUAL_PORT=9000
dev-admin.env:
APP_ENV=DEV
VIRTUAL_HOST=admin.host.dev
VIRTUAL_PORT=9000
Content of /etc/nginx/conf.d/default.conf:
# admin.host.dev
upstream admin.host.dev {
## Can be connect with "env_default" network
# admin
server 172.18.0.3:9000;
}
server {
server_name admin.host.dev;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
proxy_pass http://admin.host.dev;
}
}
# api.host.dev
upstream api.host.dev {
## Can be connect with "env_default" network
# api
server 172.18.0.4:9000;
}
server {
server_name api.host.dev;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
proxy_pass http://api.host.dev;
}
}
Full output of docker-compose up:
sudo docker-compose up --remove-orphans
Recreating admin
Recreating nginx-proxy
Recreating api
Attaching to admin, api, nginx-proxy
admin | [19-Apr-2017 15:18:24] NOTICE: fpm is running, pid 1
admin | [19-Apr-2017 15:18:24] NOTICE: ready to handle connections
api | [19-Apr-2017 15:18:24] NOTICE: fpm is running, pid 1
api | [19-Apr-2017 15:18:24] NOTICE: ready to handle connections
nginx-proxy | forego | starting dockergen.1 on port 5000
nginx-proxy | forego | starting nginx.1 on port 5100
nginx-proxy | dockergen.1 | 2017/04/19 15:18:25 Generated '/etc/nginx/conf.d/default.conf' from 3 containers
nginx-proxy | dockergen.1 | 2017/04/19 15:18:25 Running 'nginx -s reload'
nginx-proxy | dockergen.1 | 2017/04/19 15:18:25 Watching docker events
nginx-proxy | dockergen.1 | 2017/04/19 15:18:25 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx-proxy | nginx.1 | 2017/04/19 15:18:35 [error] 26#26: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.60.1, server: api.host.dev, request: "GET / HTTP/1.1", upstream: "http://172.18.0.4:9000/", host: "api.host.dev"
nginx-proxy | nginx.1 | api.host.dev 192.168.60.1 - - [19/Apr/2017:15:18:35 +0000] "GET / HTTP/1.1" 502 576 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
nginx-proxy | nginx.1 | 2017/04/19 15:18:45 [error] 26#26: *3 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.60.1, server: admin.host.dev, request: "GET / HTTP/1.1", upstream: "http://172.18.0.3:9000/", host: "admin.host.dev"
nginx-proxy | nginx.1 | admin.host.dev 192.168.60.1 - - [19/Apr/2017:15:18:45 +0000] "GET / HTTP/1.1" 502 576 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
^[[A^[[Anginx-proxy | nginx.1 | 2017/04/19 15:24:47 [error] 26#26: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.60.1, server: api.host.dev, request: "GET / HTTP/1.1", upstream: "http://172.18.0.4:9000/", host: "api.host.dev"
nginx-proxy | nginx.1 | api.host.dev 192.168.60.1 - - [19/Apr/2017:15:24:47 +0000] "GET / HTTP/1.1" 502 576 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
When using compose, each service is exposed to the other containers using its service name, as if it were a DNS hostname. So you want to change references to e.g. admin.host.dev to just admin. For example, use this:
# admin.host.dev
upstream admin.host.dev {
## Can be connect with "env_default" network
# admin
server admin:9000;
}
Notice in the server statement it now uses the hostname admin. This is automatically resolved to the container IP of your admin container.
(But note I didn't change the upstream's name - that is an internal name for nginx, and you don't necessarily need to change it.)
You would want to change the server name of the other upstream as well.

HTTP request 'Host' header not resolved on server

When i send this request:
GET /test.php HTTP/1.1
Host: localhost
The connection just times out. When looking into the server log, this is what i found:
127.0.0.1 - - [16/Nov/2016:07:58:01 +0100] "GET /test.php HTTP/1.1" 408 321 "-" "-"
Any ideas why it does that?

Resources