- 以下为
nginx.conf
,其中include /etc/nginx/conf.d/*.conf;
为了方便管理,可以将server的定义包含在conf.d
下,规划为每个conf文件负责一个server。
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.example.com;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
location / {
proxy_pass http://127.0.0.1:3032;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
- 以下为
/etc/nginx/conf.d/
目录下test.conf
server {
listen 80;
server_name test.example.com;
index index.html index.htm;
location / {
proxy_pass http://127.0.0.1:8001;
}
}
- 同时,需要在域名供应商中,将www与test记录解析到此主机。