nginx反向代理配置

  • A+
所属分类:Nginx

这里是给https://172.30.170.8:8088/vod/做代理,反向代理服务器的名称为vod.xx.xxx.cn ,监听80端口。
Apache httpd服务器监听8088端口(我这里apache与反向代理服务器在同一服务器)。

全局配置参数做些调整:

user www-data;
worker_processes 4;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
use epoll;
worker_connections 2048;
# multi_accept on;
}

http {
include /etc/nginx/mime.types;

access_log /var/log/nginx/access.log;

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_names_hash_bucket_size 256;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;

#size limits
client_max_body_size 50m;
client_body_buffer_size 256k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
#参数都有所调整.目的是解决代理过程中出现的一些502 499错误
sendfile on;
tcp_nopush on;
keepalive_timeout 120; #参数加大,以解决做代理时502错误
tcp_nodelay on;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

然后是反向代理配置了,有些参数必须调整,如client_max_body_size 不调整的话,通过web上传东西会有问题:

# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts

server {
listen 80 default;
server_name vod.xx.xxx.cn;

access_log /var/log/nginx/vod.xx.xxx.cn.access.log;

location ~ ^/status/ {
stub_status on;
access_log off;
}

location / {
proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;

proxy_pass https://172.30.170.8:8088/vod/;
}

location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
#error_page 404 /404.html;

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: