user root;
worker_processes 1;
#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 /usr/local/nginx/logs/access.log main;
sendfile on;
#tcp_nopush on;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_read_timeout 700;
proxy_send_timeout 700;
fastcgi_connect_timeout 120s;#设置为1200
fastcgi_send_timeout 120s;#设置为1200
fastcgi_read_timeout 120s;#设置为1200
fastcgi_buffers 8 128k;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
gzip on;
# 启用gzip压缩的最小文件,小于设置值的文件将不会压缩
gzip_min_length 1k;
# gzip 压缩级别,1-10,数字越大压缩的越好,也越占用CPU时间。一般设置1和2
gzip_comp_level 4;
#gzip_static on;#是否开启gzip静态资源
# 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
# 是否在http header中添加Vary: Accept-Encoding,建议开启
gzip_vary on;
# 禁用IE 6 gzip
gzip_disable "MSIE [1-6]\.";
# 设置缓存路径并且使用一块最大100M的共享内存,用于硬盘上的文件索引,包括文件名和请求次数,每个文件在1天内若不活跃(无请求)则从硬盘上淘汰,硬盘缓存最大10G,满了则根据LRU算法自动清除缓存。
proxy_cache_path /home/nginx levels=1:2 keys_zone=imgcache:100m inactive=1d max_size=10g;
upstream upstream_name1 {
server localhost:8080;
# server localhost:8081;
# server localhost:8082;
}
#生产环境 2021年09月08 本环境主要是paas组开发的工具的生产环境
server {
listen 9000;
server_name 127.0.0.1;
#charset koi8-r;
charset utf-8;
client_max_body_size 75M;
#access_log logs/host.access.log main;
location / {
root /home/paas_tool_web/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# AI工具,新版本2021年8月:
location /v2/api_ai{
proxy_pass http://127.0.0.1:8789/api_ai;
client_max_body_size 50m;
}
# 新项目Web_tool 配置
location /webmapUrl/web_tool{
proxy_pass http://127.0.0.1:8088/web_tool;
client_max_body_size 50m;
}
location /mysql_tool/api{
proxy_pass http://127.0.0.1:8089/api;
client_max_body_size 50m;
}
location ~ .*\.(gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG)$ {
expires 24h;
root /home/paas_tool_ai_backend/Smart/;#指定图片存放路径
access_log /usr/local/nginx/logs/images.log;#日志存放路径
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_temp_path /home/paas_tool_ai_backend/Smart/;#图片访问路径
proxy_redirect off;
proxy_set_header Host 127.0.0.1;
client_max_body_size 10m;
client_body_buffer_size 1280k;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 40k;
proxy_buffers 40 320k;
proxy_busy_buffers_size 640k;
proxy_temp_file_write_size 640k;
if ( !-e $request_filename)
{
proxy_pass http://127.0.0.1:8000;#默认80端口
}
}
#对接统一自动化平台,通过id获取token,正式环境和测试环境地址一样,只是正式环境的端口号是8080
#location /login {
# rewrite ^/login/(.*)$ /$1 break;
# proxy_pass http://10.154.7.12:10010;
#}
#对接cicd平台代理,
#location /cicd {
# rewrite ^/cicd/(.*)$ /$1 break;
# proxy_pass http://127.0.0.1:7088;
# }
location /files {
alias /home/files/;
autoindex on;
}
#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;
}
}
}