nginx443.conf
server{
#http2协议
listen 443 ssl http2;
server_name 10.10.101.1;
#ssl on;
ssl_certificate /etc/nginx/cert/server.crt;
ssl_certificate_key /etc/nginx/cert/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
proxy_buffering off;
#动静分离
index st/index.html;
root /opt/WEB_RELEASE/;
location /demo/{
#限流模块使用
# limit_req zone=one burst=200;
# limit_req zone=perserver burst=100;
# limit_req zone=one burst=200 nodelay;
# limit_req_status 599;
# limit_conn addr 1;
# limit_conn perserverconn 100;
# limit_conn_status 598;
#屏蔽方法
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 403;
}
#防攻击
add_header Set-Cookie "HttpOnly";
add_header Set-Cookie "Secure";
add_header X-Frame-Options "SAMEORIGIN";
real_ip_header X-Forwarded-For;
proxy_pass http://ups;
port_in_redirect off;
}
#白名单
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 65535;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
#版本号关闭
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'$upstream_addr'
' ups_resp_time:$upstream_response_time,request_time:$request_time';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
client_header_buffer_size 4k;
open_file_cache max=102400 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
client_header_timeout 15;
client_body_timeout 15;
reset_timedout_connection on;
send_timeout 15;
gzip on;
gzip_min_length 2k;
gzip_buffers 4 32k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascriptapplication/json application/javascript application/x-javascriptapplication/xml;
gzip_vary on;
gzip_proxied any;
#请求大小限制
client_max_body_size 500m;
include /etc/nginx/conf.d/*.conf;
#负载均衡
upstream ups {
server 实际ip:8002;
server 实际ip:8002;
}
## ip并发请求限制
# limit_req_zone $binary_remote_addr zone=one:10m rate=50r/s;
# limit_req_zone $server_name zone=perserver:10m rate=50r/s;
## ip 连接数限制
# limit_conn_zone $binary_remote_addr zone=addr:10m;
# limit_conn_zone $server_name zone=perserverconn:10m;
}