nginx - 使用 Cloudflare 和 nginx 的子域代理通行证
问题描述
我有一个由 Cloudflare 的免费工具管理的域。我有一个要添加的子域,名为“test”,但我希望它指向在我的服务器上运行的第二个网络服务器,端口为 8183。在 Cloudflare DNS 门户中,我有一个“test.example.com”的 A 记录,它指向到我的网络服务器的 IP 地址,该地址也被代理以隐藏我的网络服务器的实际 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
安装和使用的服务器上安装了 Origin Server Certificates。
解决方案
这可能是 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
推荐阅读
- javascript - 在javascript中从另一个列表中删除一个列表的内容时出现问题
- mongodb - 由于子数组展开后重复,Mongo 父总和错误
- java - 如何让我的程序等到任务完成后再继续?
- python - 给定小数位数的平方根近似值
- android - Where does this rocket app icon come from?
- python - 如何在python中的字符串中多次替换特定字母,
- rust - 为 Diesel“可插入”结构指定生命周期参数有什么好处
- r - r中的图中未出现岭图曲线
- tensorflow - Weight policy for imbalanced tensorflow model
- json - 如何选择名字等于孩子名字的父母