====== Engine-X web server ====== * [[https://github.com/fcambus/nginx-resources|List with nginx resources on github]] * [[https://github.com/fcambus/nginx-resources|awesome-nginx]] ===== Troubleshooting ===== ==== 413: Request Entity Too Large ==== If the size in a request exceeds the configured value, the error 413 is returned. Setting size to ''0'' disables checking of client request body size. client_max_body_size 8M; ===== Redirects ===== ==== old to new domain ==== server { listen 80; listen 443 ssl; server_name www.old-name.com old-name.com; return 301 $scheme://www.new-name.com$request_uri; } ===== Rewrites ===== https://www.nginx.com/blog/creating-nginx-rewrite-rules/ ==== userdirs ==== server { listen 80; server_name example.com; location ~ ^/~(.+?)(/.*)?$ { alias /home/$1/html$2; index index.html; autoindex on; } } ==== only if file doesn't exist ==== location / { if (-f $request_filename) { break; } rewrite ^ http://example.com$request_uri? permanent } ==== software specific ==== * [[dokuwiki#rewrites#Konfiguration|DokuWiki rewrites]] ===== php-fpm ===== ==== PHP config ==== include=/etc/php/fpm.d/*.conf [example.com] listen = /run/php-fpm/example.com.sock # owner of the socket file listen.owner = http # owner of the files in the web root user = example group = users # for low load and many pools pm = ondemand pm.max_children = 5 pm.process_idle_timeout = 10s ==== nginx config ==== === main block === worker_processes 1; error_log /var/log/nginx/error.log; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; gzip on; server { listen 80; server_name localhost; location / { root /srv/http/; index index.html index.htm index.php; autoindex on; location ~ \.php { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; include /etc/nginx/fastcgi_params } } } include /etc/nginx/sites/*.conf; } === site specific === server { listen 80; server_name example.com; root /srv/http/example.com/; location ~ ^(.+?\.php)(/.*)?$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/run/php-fpm/example.com.sock; } } ===== Reverse Proxy ===== * [[https://nginxproxymanager.com/|Nginx Proxy Manager]] – GUI for managing nginx as a proxy. Let's Encrypt support, multiple users possible. ==== Apache on port 8090 ==== location / { proxy_pass http://127.0.0.1:8090; include /etc/nginx/proxy_params; } location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$ { } ===== IPv6 ===== For nginx to listen properly on IPv6, you need two ''listen'' directives: server { listen 80; listen [::]:80; … } ===== Headers ===== ==== FLoC ==== https://amifloced.org/ server { … add_header Permissions-Policy "interest-cohort=()"; … } ===== tools ===== * [[https://nginxconfig.io/|nginxconfig.io]] – Online nginx configuration generator for general purposes[(written by DigitalOcean, code: [[https://github.com/digitalocean/nginxconfig.io|github]])]