nginx夸城市代理上网

需求:

A城市---vpn---B城市(服务器所在地),C城市访问B城市服务器的就需要走公网,所以B城市需要开通公网,但是B城市没有公网ip分配给主机,计划通过代理来上网。

方案确定为通过nginx代理,C城市----公网-------A城市---vpn-----B城市(服务器)。
1、给主机映射一个公网地址和端口。
2、域名解析
3、nginx代理配置
[root@wall nginx]$ cat nginx.conf
#basic
user nginx;   
worker_processes 1;   
pid /var/run/nginx.pid;   
worker_rlimit_nofile 202400;   
events   
{   
use epoll;   
worker_connections 202400;   
}   
http   
{   
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
  include   mime.types;   
  default_type  application/octet-stream;   
  fastcgi_intercept_errors on;   
  charset  utf-8;   
  server_names_hash_bucket_size 128;   
  client_header_buffer_size 4k;   
  large_client_header_buffers 4 32k;   
  client_max_body_size 999m;   
  sendfile on;   
  tcp_nopush  on;   
  
  keepalive_timeout 60;   
  
  tcp_nodelay on;   
  client_body_buffer_size  512k;   
  
  proxy_connect_timeout  5;   
  proxy_read_timeout   28400;   
  proxy_send_timeout   28400;   
  proxy_buffer_size  16k;   
  proxy_buffers    4 64k;   
  proxy_busy_buffers_size 128k;   
  proxy_temp_file_write_size 128k;   
  
  gzip on;   
  #gzip_disable "msie6";  
  gzip_disable "MSIE [1-6]\.";
  gzip_min_length  1k;   
  gzip_buffers   4 16k;   
  gzip_http_version 1.1;   
  gzip_comp_level 2;   
  gzip_types   text/plain application/x-javascript text/css application/xml;   
  gzip_vary on;
  
#server_tag off;
#server_info off;
#server_tokens off;


###2012-12-19 change nginx logs   
log_format  main  '$http_x_forwarded_for - $remote_user [$time_local] "$http_host" "$request" '  
    '$status $body_bytes_sent "$http_referer" '  
    '"$http_user_agent"  $request_time $remote_addr';  




##################################################################################################################
#加载vhost
include /etc/nginx/conf.d/*.conf;


}


[root@wall nginx]$ cd 
conf.d/                 fastcgi_params.default  mime.types.default      scgi_params.default     
fastcgi.conf            koi-utf                 nginx.conf              uwsgi_params            
fastcgi.conf.default    koi-win                 nginx.conf.default      uwsgi_params.default    
fastcgi_params          mime.types              scgi_params             win-utf                 
[root@wall nginx]$ cd conf.d/
[root@wall conf.d]$ ls
wall.conf
[root@wall conf.d]$ cat wall.conf 
upstream wall {
  server 192.168.1.2:80;    (B城市服务器地址)
#check interval=3000 rise=2 fall=5 timeout=30000;
}


server {


listen 83;
server_name wall*;
location /


  {
  proxy_next_upstream http_502 http_504 error timeout invalid_header;
  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_set_header X-Forwarded-Proto https;
  proxy_pass http://wall;
  expires off;
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值