Nginx 配置多域名无法访问的坑,调试了好久,才发现是小问题没处理好
http {
# sendfile使用高效文件传输,提升传输性能。启用后才能使用tcp_nopush,是指当数据表累积一定大小后才发送,提高了效率。
sendfile on;
# tcp_nopush 与 tcp_nodelay 互斥
tcp_nopush on;
# keepalive_timeout设置客户端与服务端请求的超时时间,保证客户端多次请求的时候不会重复建立新的连接,节约资源损耗。
keepalive_timeout 65;
# gzip启用压缩,html/js/css压缩后传输会更快
gzip on;
default_type application/octet-stream;
include mime.types;
include /usr/local/nginx/conf/vhosts/calligraphy.conf;
#
# 在此处 include 死活代理不了
#
#include /usr/local/nginx/conf/vhosts/publicphone.conf;
# 将 http 重定向 https
server {
listen 80;
server_name calligraphy.huayizhe.com image.calligraphy.huayizhe.com database.calligraphy.huayizhe.com publicphone.huayizhe.com;
return 301 https://$server_name$request_uri;
}
#
# 在此处 include OK了
#
include /usr/local/nginx/conf/vhosts/publicphone.conf;
}
希望朋友们 以后不要犯我一样的错误,原因是上面 include 位置的问题,导致代理不了,nginx -t 验证没问题 真实巨坑啊!