场景:服务器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

重新浏览器,可正常访问

Nginx 配置 stream SSL 第四层 代理的更多相关文章

  1. openresty(nginx) 配置 stream 转发

    nginx从1.9.0开始,新增加了一个stream模块,用来实现四层协议的转发.代理或者负载均衡等. (1)关于stream域的模块有哪些? 目前官网上列出的第三方模块.简直就是http模块的镜像. ...

  2. Nginx配置免费SSL证书StartSSL,解决Firefox不信任问题

    先在StartSSL上申请免费一年的SSL证书,具体过程网上很多教程.然后把申请到的key和crt文件上传到服务器,比如/usr/local/nginx/certs/. Nginx配置SSL证书 直接 ...

  3. Nginx配置单项SSL以及双向SSL

    Https安全协议的由来? 在实现 HTTPS协议前,我们需要了解 SSL 协议,但其实我们现在使用的更多的是 TLS 加密通讯协议. 那么TLS是怎么保证明文消息被加密的呢?在OSI七层模型中,应用 ...

  4. Nginx 配置 HTTPS SSL 代理

    配置文件如下: #user nobody; worker_processes 1; events { worker_connections 1024; } http { include mime.ty ...

  5. Nginx 配置 HTTPS SSL

    配置文件如下:[可以在阿里云上申请免费证书] #user nobody; worker_processes 1; events { worker_connections 1024; } http { ...

  6. Nginx配置客户端SSL双向认证

    对于 NGINX 的 HTTPS 配置,通常情况下我们只需要实现服务端认证就行,因为浏览器内置了一些受信任的证书颁发机构(CA),服务器端只需要拿到这些机构颁发的证书并配置好,浏览器会自己校验证书的可 ...

  7. nginx配置, 启动命令, 反向代理配置

    2014年1月3日 13:52:07 喜欢这样的风格,干货 http://huoding.com/2013/10/23/290 -----------------下边是我自己的经验(windows)- ...

  8. nginx配置本地域名反向代理实现本地多域名80访问

    什么是反向代理? 代理:通过客户机的配置,实现让一台服务器代理客户机,客户的所有请求都交给代理服务器处理. 反向代理:用一台服务器,代理真实服务器,用户访问时,不再是访问真实服务器,而是代理服务器. ...

  9. nginx配置后端映射(反向代理proxy_pass)

    说明:配置反向代理proxy_pass和location无关,location后面加不加 / 都可以 1.配置 proxy_pass 时,当在后面的 url 加上了 /,相当于是绝对路径,则 Ngin ...

随机推荐

  1. 算法笔记codeup-Contest100000566

    ABCD太直接了就不放了 E 求一元二次方根   C语言 #include <stdio.h> #include <math.h> int main() { ; ; ; sca ...

  2. ArrayList 与LinkedList 的区别及分别的优缺点

    ArrayList,与LinkedList都是属于实现了List接口的类.首先从名字前缀开始看  ,Array表示数组,Link表示链表. 所以ArrayList底层是基于动态数组的.而LinkedL ...

  3. python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'的解决方法:

    全文转载至:http://www.cnblogs.com/testyao/p/5658200.html python3中用HTMLTestRunner.py报ImportError: No modul ...

  4. 基于源代码为树莓派设备构建 TensorFlow

    本指南为运行 Raspbian 9.0 操作系统的 Raspberry Pi 嵌入式设备构建 TensorFlow.虽然这些说明可能也适用于其他系列的 Raspberry Pi 设备,但它仅针对此文中 ...

  5. Python编写的ssh客户端[类似putty]

    转载请注明出处:http://blog.csdn.net/jmppok/article/details/17588381 windows下可以通过putty以ssh方式连接linux主机.但putty ...

  6. Dubbo源码分析:ThreadPool

    定义了通过URL对象作为参数获取Executor对象的getExecutor方法.所有实现ThreadPool接口的类都是基于ThreadPoolExecuotr对象来实现的. 类图

  7. Java 多线程实战

    Java多线程 public class ThreadTest { public static void main(String[] args) throws InterruptedException ...

  8. Spark-源码分析02-Luanch Executor

    1.SparkContext.scala sparkcontext 在被new的时候,会执行class中的代码 其中有一个就是创建TaskScheduler 和 SchedulerBackend,而S ...

  9. rustup 使用

    rustup 可以帮助我们安装不同版本的rust 编程需要的工具连,同时可以方便的进行不同版本 之间的切换,类似nodejs 的nvm,n, ruby 的 rvm python 的 venv ... ...

  10. circus security 来自官方的安全建议

    转自:https://circus.readthedocs.io/en/latest/design/security/ Circus is built on the top of the ZeroMQ ...