Nginx is configured as a multi-site service under a virtual host

Source: Internet
Author: User

Nginx is configured as a multi-site service under a virtual host

Only the configuration form of a brief record does not concern more specific parameters. The following data is sample data.

Virtual Host: 122.22.22.221

Domain Name 1: cookie.com ----> site service 1: tomcat port 8080

Domain name 2: session.com -----> site service 2: tomcat port 8090

1. Check the/etc/nginx. conf configuration file to ensure that the file contains include/etc/nginx/conf. d/*. conf;

2. Switch to the/etc/nginx/conf. d directory and copy the configuration file corresponding to the default. cnf configuration domain name cookie.com.

Cp default. cnf cookie.com. cnf

3. Modify cookie.com. cnf

Vi cookie.com. cnf

Server {
Listen 80;
Server_name * .cookie.com;


# Charset koi8-r;
# Access_log/var/log/nginx/log/host. access. log main;


Location /{
Proxy_pass http: // localhost: 8080;
Index index.html index.htm;
}


# Error_page 404/404 .html;


# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/usr/share/nginx/html;
}


# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http: // 127.0.0.1;
#}


# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
# Location ~ \. Php $ {
# Root html;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
# Include fastcgi_params;
#}


# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}

}

4. Copy the configuration file corresponding to the default. cnf configuration domain name session.com.

Cp default. cnf session.com. cnf

5. Modify session.com. cnf

Vi session.com. cnf

Server {
Listen 80;
Server_name * .session.com;


# Charset koi8-r;
# Access_log/var/log/nginx/log/host. access. log main;


Location /{
Proxy_pass http: // localhost: 8090;
Index index.html index.htm;
}


# Error_page 404/404 .html;


# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/usr/share/nginx/html;
}


# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http: // 127.0.0.1;
#}


# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
# Location ~ \. Php $ {
# Root html;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
# Include fastcgi_params;
#}


# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}

}

6. Go to the domain name resolution pages of cookie.com and session.com, and add the domain name resolution A record to the VM IP122.22.22.221.

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.