nginx如何端口复用


当前第2页 返回上一页

nginx 版本

1

2

3

4

5

# docker exec -it nginx nginx -V

nginx version: nginx/1.15.10

built by gcc 8.2.0 (Alpine 8.2.0)

built with OpenSSL 1.1.1b  26 Feb 2019

...<省略若干行>...

目录文件

1

2

3

4

5

6

7

8

9

10

11

# tree ./nginx-with-L4-reuse/./nginx-with-L4-reuse/

├── config│   └── nginx

│       ├── conf.d

│       │   └── default.conf

│       ├── fastcgi.conf

│       ├── fastcgi_params

│       ├── mime.types

│       └── nginx.conf

└── docker-compose.yaml

 

3 directories, 6 files

docker-compose.yaml

1

2

3

4

5

6

7

8

9

10

11

12

# docker-compose.yaml

version: "2.4"

services:

  nginx:

    container_name: nginx

    image: nginx:alpine

    network_mode: host

    volumes:

      - ./config/nginx:/etc/nginx/:ro

    ports:

      - "443:443"

    restart: always

nginx.conf

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

user  nginx;

worker_processes  2;

 

error_log  /var/log/nginx/error.log warn;

pid        /var/run/nginx.pid;

 

 

events {

    worker_connections  1024;

}

 

stream {

    log_format stream '{"@access_time":"$time_iso8601",'

        '"clientip":"$remote_addr",'

        '"pid":$pid,'

        '"pro":"$protocol",'

        '"ssl_pro": "$ssl_preread_protocol"',

        '"pro":"$protocol",'

        '"stus":$status,'

        '"sent":$bytes_sent,'

        '"recv":$bytes_received,'

        '"sess_time":$session_time,'

        '"up_addr":"$upstream_addr",'

        '"up_sent":$upstream_bytes_sent,'

        '"up_recv":$upstream_bytes_received,'

        '"up_conn_time":$upstream_connect_time,'

        '"up_resp_time":"$upstream_first_byte_time",'

        '"up_sess_time":$upstream_session_time}';

 

    upstream ssh {

        server 192.168.50.212:22;

    }

 

    upstream web {

        server 192.168.50.215:443;

    }

 

    map $ssl_preread_protocol $upstream {

        default ssh;

        "TLSv1.2" web;

        "TLSv1.3" web;

    }

 

    # SSH and SSL on the same port

    server {

        listen 443;

 

        proxy_pass $upstream;

        ssl_preread on;

        access_log /var/log/nginx/stream_443.log stream;

    }

}

$ssl_preread_protocol 实现IP层实现了不同业务配置,在某种需求上很有意义--虽然存在功能限制。然而Tengine-2.3.0已经实现的IP层基于域名转发,或许这一特性会引入到Nginx。

更多Nginx相关技术文章,请访问Nginx使用教程栏目进行学习!

以上就是nginx如何端口复用的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

使用nginx提供静态内容服务

nginx启动失败怎么解决

深入 nginx 之配置篇

nginx能干什么

nginx常用命令介绍

nginx实现限流的方式有哪几种

负载均衡之nginx详解

nginx关闭/重启/启动方法介绍

nginx怎么绑定域名

nginx安装ssl证书的正确方法

更多相关阅读请进入《nginx》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...