版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_29843547/article/details/85090491
#worker_processes 4;
worker_processes auto;
pid /run/nginx.pid;
worker_rlimit_nofile 65335;
events {
#worker_connections 768;
worker_connections 102400;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
log_format custom '$remote_addr - $remote_user [$time_local] '
'"$request" $status $request_time $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$request_body"';
access_log /var/log/nginx/access.log custom;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
##缓存cache参数配置##
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
#缓存到nginx的本地目录
proxy_temp_path /etc/nginx/cachetemp/;
proxy_cache_path /etc/nginx/cachetemp/cache_temp levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
##end##
gzip on;
gzip_min_length 5k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 4;
gzip_types text/plain application/x-javascript text/css application/xml application/json text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
# gzip on;
# gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
upstream backendWorld {
#server 172.16.13.70;
server 172.16.13.71;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /data/world_cup_dist/dist/;
index index.html index.htm;
server_name localhost;
location / {
#try_files $uri $uri/ /index.html;
proxy_pass http://127.0.0.1:90;
}
#缓存相应的文件(静态文件)
location ~ \.(gif|jpg|png|htm|html|css|js|flv|ico|swf)(.*) {
proxy_pass http://127.0.0.1:90; #如果没有缓存则通过proxy_pass转向请求
proxy_redirect off;
proxy_set_header Host $host;
proxy_cache cache_one;
proxy_cache_valid 200 302 1h; #对不同的HTTP状态码设置不同的缓存时间,h小时,d天数
proxy_cache_valid 301 1d;
proxy_cache_valid any 1m;
expires 30d;
}
location /world_cup_api {
proxy_set_header Referer "";
proxy_pass http://backendWorld/world_cup_api;
client_max_body_size 50m;
}
location /world_cup_api_cache {
proxy_set_header Referer "";
proxy_pass http://backendWorld/world_cup_api;
client_max_body_size 50m;
proxy_set_header host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache cache_one;
proxy_ignore_headers Cache-Control;
proxy_cache_valid any 10s;
}
location /match_detail {
proxy_pass http://172.16.1.148:8888/jingcai/match_data;
#缓存相应的文件(静态文件)
proxy_redirect off;
proxy_set_header Host $host;
proxy_cache cache_one;
proxy_cache_valid 200 302 1h; #对不同的HTTP状态码设置不同的缓存时间,h小时,d天数
proxy_cache_valid 301 1d;
proxy_cache_valid any 1m;
expires 30d;
}
}
server {
listen 90;
root /data/world_cup_dist/dist/;
index index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ /index.html;
}
}
server {
listen 8081;
root /data/content/world_cup/dist/;
index index.html index.htm;
server_name localhost;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.html;
}
location /world_cup_api {
proxy_set_header Referer "";
proxy_pass http://backendWorld/world_cup_api;
client_max_body_size 50m;
}
}
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}