JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

使用 nginx来搭建正向代理服务器

wys521 2024-09-18 02:59:06 精选教程 19 ℃ 0 评论

自己有几台服务器,因为平时经常给客户采集数据,于是想把这几台服务器的IP利用起来。

心学来潮,搭建了一个简单的代理(正向代理)

配置如下

server{
      resolver 8.8.8.8;
      resolver_timeout 30s;
      listen 8880;
      server_name localhost;
      location / {
        proxy_pass http://$http_host$request_uri;
        proxy_set_header Host $http_host;
        proxy_buffers 256 4k;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout 30;
        proxy_cache_valid 301 1h;
        proxy_cache_valid any 1m;
      }
    }

只可惜,nginx可以作为http的正向代理服务器,但是不能用做https的正向代理服务器。

因为http正向代理使用的是get请求,但是https使用的确实connect请求,而nginx不支持connect请求(需要第三方模块ngx_http_proxy_connect_module 来支持https的正向代理)

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表