zoukankan      html  css  js  c++  java
  • Nginx 配置 stream SSL 第四层 代理

    场景:服务器F针对访问终端需要添加白名单操作,由到终端数量较多,所以用了一台代理服务器 P,在服务F中添加 服务器P IP地址的白名单,所有终端访问服务器P

    由于我已经安装过 Nginx 所以只需要添加模块的配置,这里先说明 stream 四层代理的实现方式,(仅满足项目需要配置,其它配置项可百度参考相应的说明)

    切换到安装目录下

    [root@localhost nginx-1.12.2]# pwd
    /usr/local/iron/nginx-1.12.2
    [root@localhost nginx-1.12.2]# 
    [root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module
    [root@localhost nginx-1.12.2]# make
    [root@localhost sbin]# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx-no-strem
    [root@localhost sbin]# cp /usr/local/iron/nginx-1.12.2/objs/nginx /usr/local/nginx/sbin/nginx
    cp:是否覆盖"/usr/local/nginx/sbin/nginx"? y
    [root@localhost sbin]# ./nginx -V
    nginx version: nginx/1.12.2
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module
    [root@localhost sbin]# 

    nginx.config

    worker_processes  1;
    
    events {
        worker_connections 1024;
    }
    
    stream { 
        map $ssl_preread_server_name $name {
            default                  backend;
        #   backend.example.com      backend2;
        }
    
    
        upstream backend {
            server ironfo.com:443;
        #    server 192.168.0.4:12345;
        }
     
        #upstream backend2 {
        #    server 192.168.0.1:12345;
        #    server 192.168.0.2:12345;
        #}
    
        server {
            listen      8080;
            proxy_pass  $name;
            ssl_preread on;
        }
    } 
    [root@localhost sbin]# /usr/local/nginx/sbin/nginx -s reload  重新加载配置文件

     

     此时访问网站会提示不安全的连接

    配置 hosts 文件(由于项目的特殊性,常不会这样的操作,没必要这么绕一圈)

    192.168.1.1 为Nginx 服务器的IP

     重新浏览器,可正常访问

     

  • 相关阅读:
    人为什么会生气 --- 答案是什么?
    职场中我们常犯的8个错误
    职场上最常见的20条错误,犯三条就够致命啦
    C语言,基于单向链表实现,变长动态数据缓冲区(线程安全) ---- 类似java的StringBuffer --- 亲测OK
    门限签名
    基于RSA的实用门限签名算法
    图解密码技术(第3版)-第4章
    各种加密算法比较
    密码那点事儿
    数字签名,我有疑问。
  • 原文地址:https://www.cnblogs.com/vipsoft/p/11530791.html
Copyright © 2011-2022 走看看