如何给nginx绑定多个端口?

发布网友

我来回答

1个回答

热心网友

在 nginx.conf 中配置多个个server即可:

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

http {
include mime.types;
default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

gzip on;

upstream localhost {
server 127.0.0.1:8080 max_fails=7 fail_timeout=7s;
}
server {
listen 81;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_pass http://localhost;
}
}
server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
proxy_pass http://localhost;
}
}
}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com