首页 > 代码库 > nginx基于端口
nginx基于端口
基于IP端口虚拟主机
如果 配置基于端口的虚拟主机,就需要每个虚拟主机配置有不同的端口
[root@localhost extra]# vim nginx_vhosts.conf
server {
listen 8060;
server_name www.you.com you.com;
location / {
root /data0/www/www;
index index.html index.htm;
access_log /app/logs/www_access.log commonlog;
}
}
######
server {
listen 8070;
server_name www.bbs.com bbs.com;
location / {
root /data0/www/bbs;
index index.html index.htm;
access_log /app/logs/bbs_access.log commonlog;
}
}
######
server {
listen 8080;
server_name www.blog.com blog.com;
location / {
root /data0/www/blog;
index index.html index.html;
access_log /app/logs/blog_access.log commonlog;
}
}
server {
listen 80;
server_name status.you.com;
location / {
stub_status on;
access_log off;
}
}
[root@localhost extra]# ../sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost extra]# ../sbin/nginx -s reload
[root@localhost extra]# netstat -tlun | grep 80
tcp 0 0 0.0.0.0:8070 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN
udp 0 0 fe80::20c:29ff:fe74:1824:123 :::*
nginx基于端口