[英]nginx subdomain not redirecting to desired port
我有一個要求,我需要將子域重定向到管理面板,並將域重定向到站點的正面部分。 我在godaddy中創建了subdoamin並在谷歌計算引擎上使用了nginx。
這是我正在使用的 nginx conf 設置:
子域規則
server {
listen 80;
listen [::]:80;
server_name admin.example.com;
root /var/www/html;
index index.html;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
主站點規則
server {
listen 80;
listen [::]:80;
server_name example.com;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
子域規則和主站點規則都在文件/etc/nginx/nginx.conf
問題是,“example.com”和“admin.example.com”都轉到“example.com”。
我想,我做了很多谷歌搜索,但沒有得到解決方案。
提前致謝。
您的子域和主站點規則相同。
root /var/www/html;
index index.html;
您可以通過創建另一個目錄和子域 conf 來解決此問題:
root /var/www/site2/html;
index index.html
使您的子域 conf 文件如下所示:
server {
listen 80;
server_name admin.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.