1. nginx部署静态网站
server
{
listen 80;
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
location / {
index beijing.html;
}
location /shenzhen {
alias /www/wwwroot/lowcarbon.pins.cn/shenzhen;
index shenzhen.html;
}
location /beijing {
alias /www/wwwroot/lowcarbon.pins.cn/beijing;
index beijing.html;
}
说明:
2. nginx可以没有默认请求设置
3. 可以通过加不同的请求头实现路由
2. nginx反向代理
server
{
listen 80;
listen 443 ssl http2;
server_name eztest.city.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/eztest.city.com;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#PHP-INFO-START PHP引用配置,可以注释或修改
include enable-php-00.conf;
#PHP-INFO-END
#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
include /www/server/panel/vhost/rewrite/eztest.city.com;
#REWRITE-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
# ez-admin
location /admin/ {
proxy_pass http://192.168.10.217:7813/;
}
location /toolbox/ {
proxy_pass http://192.168.10.217:7802/;
}
# entrance
location / {
proxy_pass http://192.168.10.217:7809/;
}
location /manager/ {
proxy_pass http://192.168.10.217:7808/;
}
location /report/ {
proxy_pass http://192.168.10.217:7815/;
}
location /scene/ {
proxy_pass http://192.168.10.217:7806/;
}
access_log /www/wwwlogs/eztest.city.com.log access_json;
error_log /www/wwwlogs/eztest.city.com.error.log;
}
3. nginx域名跳转
pin.city.com 访问 www.pin.cn
location / {
rewrite ^/(.*)$ https://www.pin.cn/$1 permanent;
}
3. 优雅关闭nginx
kill -QUIT pid
4. 检查nginx配置文件正确性
nginx -c nginx.conf -t
# 重新载入配置
nginx -s reload