worker_processes auto;
pid /var/run/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include /etc/nginx/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" $upstream_response_time $request_time';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 30; # 保持客户端与服务端的tcp连接,避免每一次请求都创建tcp通道
#fastcgi_connect_timeout 300s;
#fastcgi_send_timeout 300s;
#fastcgi_read_timeout 300s;
#fastcgi_buffer_size 256k;
#fastcgi_buffers 8 256k;#8 128
#fastcgi_busy_buffers_size 256k;
#fastcgi_temp_file_write_size 256k;
#fastcgi_intercept_errors on;
#tcp_nodelay on;
#open_file_cache max=102400 inactive=20s;
#open_file_cache_valid 120s;
#open_file_cache_min_uses 1;
#client_header_buffer_size 4k;
#client_header_timeout 300;
#client_body_timeout 300;
#client_max_body_size 20m;
#reset_timedout_connection on;
send_timeout 300;
#server_tokens off;
gzip on;
include /etc/nginx/conf.d/*.conf;
}
=======================================================
upstream mysite_app {
server 127.0.0.1:7101 weight=5;
}
server {
listen 8000;
server_name _;
### 反向代理
location /testp {
proxy_pass https://filakids.arvatocrm.cn/; #最后要加“/”
#proxy_pass http://106.75.247.236/;
}
location /api1/ {
proxy_pass http://localhost:8080;
}
# http://localhost/api1/xxx -> http://localhost:8080/api1/xxx
location /api2/ {
proxy_pass http://localhost:8080/;
}
# http://localhost/api2/xxx -> http://localhost:8080/xxx
# 静态缓存
location ~ .*\.(js|css|html|png|jpg)$ {
# cache-control优先级高于expires
# 不缓存, 测试环境只需配置这个即可
add_header Cache-Control no-store;
# 比对缓存
add_header Cache-Control no-cache;
add_header Cache-Control max-ages=10s;
expires 20s;
}
# php
location ~ \.php$ {
root /mnt/web/php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
}
# -- 带路径的配置, 比如去掉public ---
location /fila-api {
if (!-e $request_filename) {
rewrite ^/fila-api/(.*)$ /fila-api/index.php?s=/$1 last;
break;
}
alias "F:/vmshare/ello/fila-api/public/";
index index.php;
}
location ~ /fila-api/.+\.php(.*)$ {
if ($fastcgi_script_name ~ /fila-api/(.*\.php.*)$) {
set $valid_fastcgi_script_name $1;
}
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME F:/vmshare/ello/fila-api/public/$valid_fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
#uwsgi
location / {
include uwsgi_params;
uwsgi_pass mysite_app;
}
}