Show pageBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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. <code nginx> client_max_body_size 8M; </code> ===== Redirects ===== ==== old to new domain ==== <file nginx /etc/nginx/conf.d/userdirs.conf> server { listen 80; listen 443 ssl; server_name www.old-name.com old-name.com; return 301 $scheme://www.new-name.com$request_uri; } </file> ===== Rewrites ===== https://www.nginx.com/blog/creating-nginx-rewrite-rules/ ==== userdirs ==== <file nginx /etc/nginx/conf.d/userdirs.conf> server { listen 80; server_name example.com; location ~ ^/~(.+?)(/.*)?$ { alias /home/$1/html$2; index index.html; autoindex on; } } </file> ==== only if file doesn't exist ==== <file nginx /etc/nginx/conf.d/userdirs.conf> location / { if (-f $request_filename) { break; } rewrite ^ http://example.com$request_uri? permanent } </file> ==== software specific ==== * [[dokuwiki#rewrites#Konfiguration|DokuWiki rewrites]] ===== php-fpm ===== ==== PHP config ==== <file ini /etc/php/php-fpm.conf> include=/etc/php/fpm.d/*.conf </file> <file ini /etc/php/fpm.d/example-com.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 </file> ==== nginx config ==== === main block === <file nginx /etc/nginx/nginx.conf> 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; } </file> === site specific === <file nginx /etc/nginx/sites/com.example.subdomain.conf> 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; } } </file> ===== 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 ==== <file nginx /etc/nginx/conf.d/userdirs.conf> 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)$ { } </file> ===== IPv6 ===== For nginx to listen properly on IPv6, you need two ''listen'' directives: <code nginx> server { listen 80; listen [::]:80; … } </code> ===== Headers ===== ==== FLoC ==== https://amifloced.org/ <code nginx> server { … add_header Permissions-Policy "interest-cohort=()"; … } </code> ===== tools ===== * [[https://nginxconfig.io/|nginxconfig.io]] – Online nginx configuration generator for general purposes[(written by DigitalOcean, code: [[https://github.com/digitalocean/nginxconfig.io|github]])] Last modified: 2024-07-05 14:31