zoukankan      html  css  js  c++  java
  • nginx转发https协议

    1,需求

    内网需要访问github.com,并且是按照https://github.com这样的访问方式进行访问。

    因为使用了npm install git+https://github.com/xxx/xxx.git之类的命令。

    2,编译nginx增加stream、ssl相关模块

    ./configure --prefix=/etc/nginx/ 
    --sbin-path=/usr/sbin/nginx
    --conf-path=/etc/nginx/nginx.conf
    --error-log-path=/var/log/nginx/error.log
    --http-log-path=/var/log/nginx/access.log
    --pid-path=/var/run/nginx.pid
    --lock-path=/var/run/nginx.lock
    --with-stream
    --with-stream_ssl_module
    --with-stream_ssl_preread_module
    --with-openssl=/path/to/openssl-1.0.2j
    --with-pcre=/path/to/pcre-8.38

    3,增加stream、ssl转发配置

    在nginx.conf中进行stream配置

    stream {
    
      map $ssl_preread_server_name $backend_pool {
        github.com github;
        codeload.github.com codegithub;
      }
    
      upstream github{
        server github.com:443;
      }
    
      upstream codegithub{
        server codeload.github.com:443;
      }
    
      server{
        listen 443;
        ssl_preread on;
        proxy_pass $backend_pool;
        proxy_connect_timeout 15s;
        proxy_timeout 15s;
        proxy_next_upstream_timeout 15s;
      }
    
    }

    4,本地hosts文件配置

    在中转服务器端需要配置github.com相关的hosts解析;

    在本地hosts文件中,直接将github.com解析到中转服务器;

  • 相关阅读:
    PHP 缓存技术
    redis雪崩
    【Redis】- 缓存击穿
    Memcache 与 Memcached 的区别
    数据库设计:范式与反范式
    Thinkphp5多数据库切换
    PHP 分布式集群中session共享问题以及session有效期的设置
    Nginx使用upstream实现动静分离
    rsync 服务快速部署手册
    tp5 为什么使用单例模式
  • 原文地址:https://www.cnblogs.com/stono/p/14097791.html
Copyright © 2011-2022 走看看