Nginx 反向代理

Http,https 反向代理,将下面的内容保存于xxx.conf 文件,放在 /etc/nginx/conf.d/ 文件夹下

server {

listen 80;

listen [::]:80;

client_max_body_size 300M;

# nginx uses the custom resolver if proxy pass is set as an variable

# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

server_name test01.xxx.com;

set $backend http://test01.xxx.com:8080;

resolver 127.0.0.11 [::1]:5353 valid=1s;

location / {

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass $backend;

}

}

server {

    listen 443;
ssl on;
ssl_certificate /etc/nginx/test01.crt;
ssl_certificate_key /etc/nginx/test01.key;

client_max_body_size 300M;

# nginx uses the custom resolver if proxy pass is set as an variable

# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

server_name test01.xxx.com;

set $backend http://test01.xxx.com:8080;

resolver 127.0.0.11 [::1]:5353 valid=1s;

location / {

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass $backend;

}

}

Leave a Comment