• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    使用nginx设置代理服务器

    nginx可以利用其反向代理的功能来进行负载均衡的实现,同时也可以使用其正向代理的功能设置代理服务器,比如在内网的环境中,在可以连接外网的机器上运行nginx作为代理服务器,其他机器通过设定此台机器的IP和port即可通过其连接上网,本文使用nginx官方镜像,通过如下步骤即可简单实现代理服务器。

    Step 1: 启动nginx

    [root@devops ~]# docker run -p 8888:8888 --name proxy-nginx -d nginx
    c7baab8ea9da0a148aa9bcc1295a54391906f6be94efca7189df23ceecdbf714
    [root@devops ~]#

    Step 2: 设定nginx

    进入容器中

    [root@devops ~]# docker exec -it proxy-nginx sh

    update apt-get

    安装ping/vi/ps:apt-get update; apt-get install procps vim inetutils-ping

    设定nginx.conf

    加入如下内容,即可实现最简单的代理功能

      resolver   8.8.8.8;
      server {
        listen 8888;
        location / {
          proxy_pass http://$http_host$request_uri;
        }
      }

    其余信息均为nginx.conf的确认内容,未做修改

    # cat nginx.conf
    user nginx;
    worker_processes 1;
    error_log /var/log/nginx/error.log warn;
    pid    /var/run/nginx.pid;
    events {
      worker_connections 1024;
    }
    http {
      include    /etc/nginx/mime.types;
      default_type application/octet-stream;
      log_format main '$remote_addr - $remote_user [$time_local] "$request" '
               '$status $body_bytes_sent "$http_referer" '
               '"$http_user_agent" "$http_x_forwarded_for"';
      access_log /var/log/nginx/access.log main;
      sendfile    on;
      #tcp_nopush   on;
      keepalive_timeout 65;
      #gzip on;
      resolver   8.8.8.8;
      server {
        listen 8888;
        location / {
          proxy_pass http://$http_host$request_uri;
        }
      }
      include /etc/nginx/conf.d/*.conf;
    }
    #

    Step 4: 设定客户端

    在客户端设定服务器IP和上述的端口8888,即可通过改代理服务器连接网络。

    总结

    以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对脚本之家的支持。如果你想了解更多相关内容请查看下面相关链接

    上一篇:Nexus使用Api进行操作
    下一篇:使用squid搭建http和https的代理服务器设置指南
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    使用nginx设置代理服务器 使用,nginx,设置,代理,服务器,