vps - How to configure nginx for multiple site applications under one domain name?
为情所困2017-05-16 17:20:47
0
2
564
Like this www.example.com blog.example.com But different applications, for example www.example.com is a static page, and blog.example.com is a nodejs application Can it be done? How to configure it specifically?
Configure the virtual host Post the pseudo code for reference
Add at the end of the server section of the configuration file nginx.conf
include vhost/*.conf;
Create the vhost directory Create files in the vhost directory, such as www.example.com.conf, blog.example.com.conf Then make the following configuration
server
{
listen 80;
server_name www.example.com;
index index.php index.html index.htm ;
root /var/www/www.example.com;
if ( $fastcgi_script_name ~ \..*\/.*php ) {
return 403;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Of course, nodejs does not rely on ng. ng specifies the nodejs application folder. Domain name access only triggers initialization, and other communication and explanations are returned to the node service
Configure root for the static page and configure the reverse proxy for the application
Configure the virtual host
Post the pseudo code for reference
Add at the end of the server section of the configuration file nginx.conf
Create the vhost directory
Create files in the vhost directory, such as www.example.com.conf, blog.example.com.conf
Then make the following configuration
Of course, nodejs does not rely on ng. ng specifies the nodejs application folder. Domain name access only triggers initialization, and other communication and explanations are returned to the node service