nginx如何设置多端口


当前第2页 返回上一页

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

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

user nginx nginx;

worker_processes  1;

worker_rlimit_nofile 65535;

events {

    worker_connections  4000;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    autoindex off;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"'

                       '$upstream_addr $upstream_response_time $request_time ';

    access_log  logs/nginx/access.log main;

    sendfile        on;

    keepalive_timeout  65;

        upstream localhost {

        server 127.0.0.1:8080 max_fails=7 fail_timeout=7s;

    }

    server {

        listen       808;

        server_name  localhost;

                large_client_header_buffers 4 128k;

        client_max_body_size 300m;

        client_body_buffer_size 128k;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;

        proxy_buffer_size 64k;

        proxy_buffers   4 32k;

        proxy_busy_buffers_size 64k;

        proxy_temp_file_write_size 64k;

#设定查看Nginx状态的地址

        location /nginxstatus{

            stub_status on;

            access_log on;

            auth_basic "nginxstatus";

            auth_basic_user_file htpasswd;

    }

#ftpweb

         location /ftpweb {

           index  index.html index.htm index.jsp;

           proxy_pass  http://192.168.0.16:9081/ftpweb;

           proxy_set_header X-Real-IP $remote_addr;

           proxy_set_header Host $host:$server_port;

        }

#Zabbixweb

         location /webzabbix/ {

           index  index.html index.htm index.jsp;

           proxy_pass  http://192.168.0.15/zabbix/;

           proxy_set_header X-Real-IP $remote_addr;

           proxy_set_header Host $host:$server_port;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

    server {

        listen       8098;

        server_name  localhost;

        large_client_header_buffers 4 128k;

        client_max_body_size 300m;

        client_body_buffer_size 128k;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;

        proxy_buffer_size 64k;

        proxy_buffers   4 32k;

        proxy_busy_buffers_size 64k;

        proxy_temp_file_write_size 64k;

#开放8098接口地址

         location /interserver {

           index  index.html index.htm index.jsp;

           proxy_pass  http://192.168.0.20:8812/interserver/;

           proxy_set_header X-Real-IP $remote_addr;

           proxy_set_header Host $host:$server_port;

        }

    }

}

这样就就可以一个nginx服务访问808和8098两个端口到不同服务的了

http://192.168.0.15:808/ftpweb

http://192.168.0.15:8098/interserver

更多Nginx相关知识,请访问Nginx使用教程栏目!

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

返回前面的内容

相关阅读 >>

nginx如何设置多端口

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



打赏

取消

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

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

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

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

评论

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