Docker Network Nginx Resolver

First off, you should be using the Docker embedded DNS server at 127.0.0.11. Your problem could be caused by 1 of the following: nginx is trying to use IPv6 (AAAA record) for the DNS queries. See https://stackoverflow.com/a/35516395/1529493 for the solution. Basically something like: http { resolver 127.0.0.11 ipv6=off; } This is probably no longer a … Read more

Logging POST data from $request_body

This solution works like a charm: http { log_format postdata $request_body; server { location = /post.php { access_log /var/log/nginx/postdata.log postdata; fastcgi_pass php_cgi; } } } I think the trick is making nginx believe that you will call a CGI script. Edit 2022-03-15: there is some discussion on where log_format should be set. The documentation clearly … Read more

Nginx causes 301 redirect if there’s no trailing slash

I posted a possible solution to this problem on serverfault; reproduced here for convenience: If I understand the question correctly, you want to automatically serve, without using a 301 redirect, http://example.com/foo/index.html when the request is for http://example.com/foo with no trailing slash? Basic solution that works for me If so I’ve found this try_files configuration to … Read more

nginx: connect() failed (111: Connection refused) while connecting to upstream

I don’t think that solution would work anyways because you will see some error message in your error log file. The solution was a lot easier than what I thought. simply, open the following path to your php5-fpm sudo nano /etc/php5/fpm/pool.d/www.conf or if you’re the admin ‘root’ nano /etc/php5/fpm/pool.d/www.conf Then find this line and uncomment … Read more

Use nginx to serve static files from subdirectories of a given directory

It should work, however http://nginx.org/en/docs/http/ngx_http_core_module.html#alias says: When location matches the last part of the directive’s value: it is better to use the root directive instead: which would yield: server { listen 8080; server_name www.mysite.com mysite.com; error_log /home/www-data/logs/nginx_www.error.log; error_page 404 /404.html; location /public/doc/ { autoindex on; root /home/www-data/mysite; } location = /404.html { root /home/www-data/mysite/static/html; } … Read more

How to fix “mbind: Operation not permitted” in mysql error log

Add the capability CAP_SYS_NICE to your container until MySQL server can handle the error itself “silently”. service: mysql: image: mysql:8.0.15 # … cap_add: – SYS_NICE # CAP_SYS_NICE If you don’t have docker-compose, then you can define CAP_SYS_NICE via docker run –cap-add=sys_nice -d mysql References: Docker Seccomp security profiles: https://docs.docker.com/engine/security/seccomp/ Docker resource constraints: https://docs.docker.com/config/containers/resource_constraints/

How to serve all existing static files directly with NGINX, but proxy the rest to a backend server.

Use try_files and named location block (‘@apachesite’). This will remove unnecessary regex match and if block. More efficient. location / { root /path/to/root/of/static/files; try_files $uri $uri/ @apachesite; expires max; access_log off; } location @apachesite { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8080; } Update: The assumption of this config is that … Read more

Nginx will not start (Address already in use)

Probably other process is using specified port: sudo netstat -tulpn Get the PID of the process that already using 443. And send signal with kill command. sudo kill -2 <PID> sudo service nginx restart Aternatively you can do: sudo fuser -k 443/tcp Make sure you dont use old syntax: server { listen :80; listen [::]:80; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)