今天,终于把WINDOWS下的反向代理配置成功了,这样美国的网站就可以实现加速了,由于各地网络的不同,有些地区访问美国的VPS速度确认不行,经常性的出现丢包的现象,所以很有必要在香港弄一个VPS来当做反向代理,比较简单的,就是使用nginx了。
下面是nginx.conf标准的配置:
worker_processes 2;
error_log logs/error.log notice;
pid logs/nginx.pid;
worker_rlimit_nofile 5120;
events {
worker_connections 5120;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
limit_conn_zone $binary_remote_addr zone=one:32k;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format logs '$remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for';
#include default.conf;
include vhost/*.conf;
}
上面的是主程序的配置文件,然后你在vhost目录下创建虚拟网站即可,虚拟网站的配置如下:
server{
listen 80;
server_name hongkong.030904.com hongkong.030904.net;
location / {
proxy_pass http://usa.030904.com/;
proxy_redirect off;
# proxy_set_header Host $host; 这个要注释掉,否则可能出现Invalid Hostname的错误
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
随便保存一个hongkong.conf的名字即可。
本文由山坛兄弟原创或编辑,转载请保留链接【nginx反向代理配置以及常见问题】http://www.030904.net/computer/128.html