查看Nginx配置
- 查看Nginx配置
- 查看Nginx域名
- Nginx配置常识
查看Nginx配置
/xy/server/nginx/conf/nginx.conf
user www; worker_processes 4; daemon on; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #client_max_body_size 128M; client_max_body_size 128M; #gzip on; #server { #listen 80; #server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; # location / { # root html; # index index.html index.htm; # } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # root html; # } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} #} # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} include vhosts/*.conf; #include vhosts/zz.*.conf; #include vhosts/backend.*.conf; #include vhosts/20241019.*.conf; }
查看Nginx域名
- zzroo.com
#zzroo.com server { #listen 80; listen 443 ssl; ssl_certificate /xy/server/nginx/conf/ssl/202504/zzroo.com_nginx/zzroo.com_bundle.crt; ssl_certificate_key /xy/server/nginx/conf/ssl/202504/zzroo.com_nginx/zzroo.com.key; ssl_session_timeout 30d; #请按照以下协议配置 ssl_protocols TLSv1.2 TLSv1.3; #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; server_name zzroo.com; root "/xy/www/zz_deet/web"; access_log /xy/server/nginx/logs/zzroo.com-access.log; error_log /xy/server/nginx/logs/zzroo.com-error.log; location / { try_files $uri $uri/ /index.php?$args; index www.php index.html error/index.html; error_page 400 /error/400.html; error_page 403 /error/403.html; error_page 404 /notFound; error_page 500 /error/500.html; error_page 501 /error/501.html; error_page 502 /error/502.html; error_page 503 /error/503.html; error_page 504 /error/504.html; error_page 505 /error/505.html; error_page 506 /error/506.html; error_page 507 /error/507.html; error_page 509 /error/509.html; error_page 510 /error/510.html; autoindex on; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index www.php; try_files $uri /www.php =404; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; # try_files $uri /index.php =404; } #站点目录 location ^~ /net/ { root "/xy/www"; expires 30d; add_header Cache-Control "public"; try_files $uri $uri/ =404; } #静态资源目录 location ~ \.(js|css|jpg|jpeg|png|gif|html|htm|bmp|ico|txt|css|xlsx|svg)(.*)$ { root "/xy/www/zz_deet/web-www/resources"; expires 30d; add_header Cache-Control "public"; try_files $uri $uri/ =404; } #上传目录 location ^~ /upload/ { root "/xy/www/zz_deet/web-www/storage"; expires 30d; add_header Cache-Control "public"; try_files $uri $uri/ =404; } } #微框架 server { #listen 80; listen 443 ssl; ssl_certificate /xy/server/nginx/conf/ssl/202502/mini.zzroo.com_nginx/mini.zzroo.com_bundle.crt; ssl_certificate_key /xy/server/nginx/conf/ssl/202502/mini.zzroo.com_nginx/mini.zzroo.com.key; ssl_session_timeout 30d; #请按照以下协议配置 ssl_protocols TLSv1.2 TLSv1.3; #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; server_name mini.zzroo.com; root "/xy/www/20241019/web"; access_log /xy/server/nginx/logs/mini.zzroo.com-access.log; error_log /xy/server/nginx/logs/mini.zzroo.com-error.log; location / { index index.php; autoindex on; try_files $uri $uri/ /index.php?$args; } #脚本处理入口 location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; try_files $uri /index.php =404; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param PLATFORM frontend; include fastcgi_params; } } #后台 server { # listen 80; listen 443 ssl; ssl_certificate /xy/server/nginx/conf/ssl/202504/admin.zzroo.com_nginx/admin.zzroo.com_bundle.crt; ssl_certificate_key /xy/server/nginx/conf/ssl/202504/admin.zzroo.com_nginx/admin.zzroo.com.key; ssl_session_timeout 30d; #请按照以下协议配置 ssl_protocols TLSv1.2 TLSv1.3; #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; server_name admin.zzroo.com; root "/xy/www/zz_deet/web"; access_log /xy/server/nginx/logs/admin.zzroo.com-access.log; error_log /xy/server/nginx/logs/admin.zzroo.com-error.log; location / { index admin.php; error_page 404 /notFound; autoindex on; try_files $uri $uri/ /admin.php?$args; } #脚本处理入口 location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index admin.php; try_files $uri /admin.php =404; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param PLATFORM backend; include fastcgi_params; } #静态资源代理 location ~ \.(js|css|jpg|jpeg|png|gif|html|htm|bmp|ico|txt|css|xlsx|svg)(.*)$ { root "/xy/www/zz_deet/web-admin/resources"; expires 30d; add_header Cache-Control "public"; try_files $uri $uri/ =404; } #上传目录 location ^~ /upload/ { root "/xy/www/zz_deet/web-admin/storage"; expires 30d; add_header Cache-Control "public"; try_files $uri $uri/ =404; } } #http请求向https转发 server { listen 80; server_name admin.zzroo.com mini.zzroo.com zzroo.com www.zzroo.com; return 301 https://$host$request_uri; }
Nginx配置常识
可以通过配置PHP脚本处理,传递配置参数给PHP fastcgi_param PLATFORM frontend; server { listen 80; server_name swoole.test; location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:9501; } }