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.