admin:nginx

Engine-X web server

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;
/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;
}
/etc/nginx/conf.d/userdirs.conf
server {
  listen 80;
  server_name example.com;
  location ~ ^/~(.+?)(/.*)?$ {
    alias /home/$1/html$2;
    index index.html;
    autoindex on;
  }
}
/etc/nginx/conf.d/userdirs.conf
location / {
    if (-f $request_filename) {
        break;
    }
    rewrite ^ http://example.com$request_uri? permanent
}
/etc/php/php-fpm.conf
include=/etc/php/fpm.d/*.conf
/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

main block

/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;
}

site specific

/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;
	}
}
  • Nginx Proxy ManagerGUI for managing nginx as a proxy. Let's Encrypt support, multiple users possible.
/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)$ {
       }

For nginx to listen properly on IPv6, you need two listen directives:

server {
        listen 80;
        listen [::]:80;}

https://amifloced.org/

server {add_header Permissions-Policy "interest-cohort=()";}
  • nginxconfig.io – Online nginx configuration generator for general purposes1

[1] written by DigitalOcean, code: github
  • Last modified: 2024-07-05 14:31