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

     重新浏览器,可正常访问

     

  • 相关阅读:
    Python字符串的定义与常用操作
    Python中yield返回生成器的详细方法
    python中把列表中的字符串转成整型的3种方法
    python基础教程:修改Python列表中元素的几种方法
    极致性能设计——开篇
    MySQL设计与实现
    Java平台标准版工具参考
    为什么for循环中的a=a++,a总是0
    JVM 分析工具快速查询手册
    从现代计算机低层看待性能和并发
  • 原文地址:https://www.cnblogs.com/vipsoft/p/11530791.html
Copyright © 2011-2022 走看看