Initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
# 开启Gzip全局压缩(文本类压缩60%-80%)
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip_vary on;
|
||||
|
||||
# PHP统一解析 + 优化参数
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# PHP-FPM优化:减少等待超时
|
||||
fastcgi_connect_timeout 60s;
|
||||
fastcgi_send_timeout 60s;
|
||||
fastcgi_read_timeout 60s;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 128k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
fastcgi_temp_file_write_size 256k;
|
||||
}
|
||||
|
||||
# 首页通用路由
|
||||
location / {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# api目录转发
|
||||
location /api/ {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# 静态资源统一长期缓存(图片、样式、脚本、字体合并规则)
|
||||
location ~* \.(jpg|jpeg|png|gif|webp|ico|css|js|woff|woff2|ttf)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# 禁止外部直接访问cache缓存目录,返回403
|
||||
location ^~ /cache/ {
|
||||
deny all;
|
||||
return 403;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
# 统一PHP解析规则(所有目录下.php文件都交给php-fpm解析)
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
# 自动获取当前请求php文件真实路径,支持任意php文件
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
# 前端静态页面、目录访问
|
||||
location / {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# /api 仅路由,不用重复配置php,上面正则会自动处理
|
||||
location /api/ {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
# 开启Gzip全局压缩(文本类压缩60%-80%)
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip_vary on;
|
||||
|
||||
# PHP统一解析 + 优化参数
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# PHP-FPM优化:减少等待超时
|
||||
fastcgi_connect_timeout 60s;
|
||||
fastcgi_send_timeout 60s;
|
||||
fastcgi_read_timeout 60s;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 128k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
fastcgi_temp_file_write_size 256k;
|
||||
}
|
||||
|
||||
# 首页通用路由
|
||||
location / {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# api目录转发
|
||||
location /api/ {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# 静态资源专项缓存(头像、js、css、字体)
|
||||
location ~* \.(jpg|jpeg|png|gif|webp|ico)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
access_log off;
|
||||
}
|
||||
location ~* \.(js|css|woff|woff2|ttf)$ {
|
||||
expires 3d;
|
||||
add_header Cache-Control "public, max-age=259200";
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip_vary on;
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
fastcgi_connect_timeout 60s;
|
||||
fastcgi_send_timeout 60s;
|
||||
fastcgi_read_timeout 60s;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 128k;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# 静态资源长期缓存
|
||||
location ~* \.(jpg|jpeg|png|gif|webp|ico)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
access_log off;
|
||||
}
|
||||
location ~* \.(js|css|woff|woff2|ttf)$ {
|
||||
expires 3d;
|
||||
add_header Cache-Control "public, max-age=259200";
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
# 开启Gzip压缩,提升页面加载速度
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
gzip_vary on;
|
||||
|
||||
# PHP解析配置
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# 优化PHP连接超时、缓冲区
|
||||
fastcgi_connect_timeout 60s;
|
||||
fastcgi_send_timeout 60s;
|
||||
fastcgi_read_timeout 60s;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 128k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
fastcgi_temp_file_write_size 256k;
|
||||
}
|
||||
|
||||
# 首页通用路由
|
||||
location / {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# API目录
|
||||
location /api/ {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# 静态资源长期缓存(本地static目录js/css/图片)
|
||||
location ~* \.(jpg|jpeg|png|gif|webp|ico)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
access_log off;
|
||||
}
|
||||
location ~* \.(js|css|woff|woff2|ttf)$ {
|
||||
expires 3d;
|
||||
add_header Cache-Control "public, max-age=259200";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# 禁止访问缓存目录cache,防止外部直接下载缓存文件
|
||||
location ^~ /cache/ {
|
||||
deny all;
|
||||
return 403;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
# 前端静态页面
|
||||
location / {
|
||||
try_files $uri $uri/;
|
||||
}
|
||||
|
||||
# PHP告警接口
|
||||
location /api {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/api/index.php;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user