#--- 代理服务器(外层nginx) ---#
nginx 子站点配置文件: /www/www/wwwconf/www.conf
#分站子站转发配置,再server 板块的 location 方法里面
server{
listen 80;
server_name work.eisc.cn;
location / {
proxy_pass http://work.eisc.cn;
#--- 将ip 记录下来,传递给后端服务器 ---#
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
nginx -s reload # nginx 配置生效,或者重启nginx
#--- web 服务器(后端 nginx)---#
nginx 主配置文件,非子站点:
# 再 http 板块:案例下面位置处:
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
#--------- 配置可见ip ---------#
set_real_ip_from 10.111.111.1;
real_ip_header X-Forwarded-For;
# 填写实际的内网请求来源 ip
# 作用: 将内网ip 进行替换成客户端实际 ip
#------------------------------#
#--- nginx 主配置文件案例 ---#
user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
#--------- 配置可见ip ---------#
set_real_ip_from 10.111.111.1;
real_ip_header X-Forwarded-For;
#--------------- 开启gzip 压缩 ---------------#
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
#---------------------------------------------------#
server_tokens off;
access_log off; # 关闭日志
include /www/wwwroot/wwwconf/*.conf;
}
阿里云配置教程: https://help.aliyun.com/document_detail/54007.html
第三方教程:https://www.cnblogs.com/wangxu01/articles/11243496.html