如何解决使用Cloudflare和Nginx的子域代理通过
我有一个由Cloudflare的免费工具管理的域。我有一个要添加的名为“ test”的子域,但我希望它指向运行在服务器上端口8183上的第二个网络服务器。在Cloudflare DNS门户中,我有一个指向“ test.example.com”的A记录,该指向到我的Web服务器的IP地址,该地址也被用来隐藏我的Web服务器的实际IP地址。所有流量均通过HTTPS路由,该证书也由Cloudflare提供。
我的nginx default.conf:
# Redirect all traffic to HTTPS/443/SSL
server {
server_name example.com *.example.com;
listen 80;
return 301 https://$host$request_uri;
}
# example.com
server {
server_name example.com;
listen 443 ssl;
index index.php index.html;
ssl_certificate /etc/ssl/origincert.pem;
ssl_certificate_key /etc/ssl/privkey.key;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /website;
location ~ \.php$ {
autoindex on;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
# test.example.com -> proxy pass to 8183
server {
server_name test.example.com;
listen 443 ssl;
ssl_certificate /etc/ssl/origincert.pem;
ssl_certificate_key /etc/ssl/privkey.key;
location / {
proxy_pass http://MY_SERVER_IP_ADDRESS:8183;
}
}
但是,当我导航到https://test.example.com
或http
时,我只是被重新路由到https://example.com
。我的服务器上安装了原始服务器证书,并且已经安装并使用了example.com,*.example.com,and test.example.com
。
解决方法
这可能是 DNS 记录的问题。检查它们并确保没有像 *.example.com -> example.com
这样的记录
确保 test
子域直接指向您服务器的 IP 地址,与 example.com
相同。
所以如果你有
example.com -> 1.2.3.4
确保你也有
test.example.com -> 1.2.3.4.
而不是 test.example.com -> example.com
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。