As follows:
server {
listen 80;
server_name dev.drpb.com;
root /Users/Stone/repo/oschina/drsoft/page-builder;
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
}
server {
listen 80;
server_name dev.drp.com;
root /Users/Stone/repo/oschina/drsoft/site;
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
}
There are two server configuration blocks in the nginx configuration, and they have a common php reverse proxy configuration part.
How to add:
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
Extract it and put it in one place instead of writing it once in each server (I tried putting it in the http block of its common parent but it didn't work), thank you!
阿神2017-05-16 17:18:37
Answer found:
Extract the location part to an external file, for example, name it: common_rules.conf, and put it in the nginx directory.
Modify the server configuration to:
server {
server_name dev.drpb.com;
root /Users/Stone/repo/oschina/drsoft/page-builder;
include common_rules.conf;
}
server {
server_name dev.drp.com;
root /Users/Stone/repo/oschina/drsoft/site;
include common_rules.conf;
}