Nginx Port-based virtual host configuration

Source: Internet
Author: User

The application of the port-based virtual host in the production environment is rare, only occasionally used, a move is for the company's internal personnel to provide access, such as the background of the page, CMS release, phpMyAdmin and so on.

1. Configuring the Listening port

[Email protected]]# VI nginx_vhosts.conf

server {

Listen 8060;

server_name www.etiantian.org;

Location/{

root/data0/www/www;

Index index.html index.htm;

Access_log/app/logs/www_access.logmain;

}

}

###

server {

Listen 8070;

server_name bbs.etiantian.org;

Location/{

Root/data0/www/bbs;

Index index.html index.htm;

Access_log/app/logs/bbs_access.logmain;

}

}

###

server {

Listen 8080; # This port is causing a sequel

server_name blog.etiantian.org etiantian.org;

Location/{

Root/data0/www/blog;

Index index.html index.htm;

Access_log/app/logs/blog_access.log main;

}

}

# # #配置ngnix状态虚拟主机信息

Server

{

Listen 80;

server_name status.etiantian.org;

Location/{

Stub_status on;

Access_log off;

}

}

[Email protected]]#. /.. /sbin/nginx-t

Nginx:the configuration File/application/nginx-1.10.1/conf/nginx.confsyntax is ok

Nginx:configuration File/application/nginx-1.10.1/conf/nginx.conftest is successful

[Email protected]]#. /.. /sbin/nginx-s Reload

[[Email protected]]# netstat-lnt|grep 8 # above 3 ports are not listening, the reason is 8080 Port conflict, Tomcat is also set to port 8080

TCP 0 0 0.0.0.0:32803 0.0.0.0:* LISTEN

TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN

TCP 0 0::: 32803:::* LISTEN

TCP 0 0:: ffff:127.0.0.1:8005:::* LISTEN

TCP 0 0::: 8009:::* LISTEN

TCP 0 0::: 8080:::* LISTEN

[Email protected]]# VI nginx_vhosts.conf

server {

Listen 8060;

server_name www.etiantian.org;

Location/{

root/data0/www/www;

Index index.html index.htm;

Access_log/app/logs/www_access.logmain;

}

}

###

server {

Listen 8070;

server_name bbs.etiantian.org;

Location/{

Root/data0/www/bbs;

Index index.html index.htm;

Access_log/app/logs/bbs_access.log main;

}

}

###

server {

Listen 8081;

server_name blog.etiantian.org etiantian.org;

Location/{

Root/data0/www/blog;

Index index.html index.htm;

}

}

[Email protected]]#. /.. /sbin/nginx-t

Nginx:the configuration File/application/nginx-1.10.1/conf/nginx.confsyntax is ok

Nginx:configuration File/application/nginx-1.10.1/conf/nginx.conftest is successful

[Email protected]]#. /.. /sbin/nginx-s Reload

[[Email protected]]# netstat-lnt|grep 80

TCP 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN

TCP 0 0 0.0.0.0:32803 0.0.0.0:* LISTEN

TCP 0 0 0.0.0.0:8070 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:8081 0.0.0.0:* LISTEN

TCP 0 0::: 32803:::* LISTEN

TCP 0 0:: ffff:127.0.0.1:8005:::* LISTEN

TCP 0 0::: 8009:::* LISTEN

TCP 0 0:::8080 :::*

Access test:

The following 3 addresses are accessed through a browser : The test results are as follows:

http://www.etiantian.org:8060/

http://www.etiantian.org:8070/

http://www.etiantian.org:8081/

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/83/5B/wKioL1dxOQ6xMZTsAABSu3QmrYA002.png-wh_500x0-wm_3 -wmp_4-s_2961849441.png "title=" Untitled. png "alt=" wkiol1dxoq6xmztsaabsu3qmrya002.png-wh_50 "/>


This article is from the "sky9890" blog, make sure to keep this source http://sky9896.blog.51cto.com/2330653/1793454

Nginx Port-based virtual host configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.