![](/img/trans.png)
[英]Nginx server multiple site and domain redirection (on same port/different port)
[英]How to accept request with port after domain in nginx
我有一個子域https://test.shop.com
,我正在運行 Nginx 服務器,它工作正常。 但是我必須接受https://test.shop.com:8080/graphql/
的請求並重定向到http://127.0.0.1:8000
到同一台機器。 我已經添加了這個塊
location /graphql/ {
proxy_pass http://127.0.0.1:8000;
}
但是當我嘗試從瀏覽器訪問https://test.shop.com:8080/graphql/
時,它向我顯示無法訪問此站點似乎與 ZB3BF60B851EBAEB22368B01A32E2 有關。 雖然我可以訪問https://test.shop.com/graphql/
並且工作正常。
我的整個配置文件是
server {
server_name test.shop.com;
root /var/www/html/test;
index index.html;
location / {
try_files $uri $uri/ /index.html?$args;
}
# dashboard app
location /dashboard/ {
try_files $uri $uri/ /dashboard/index.html?$args;
}
location /graphql/ {
proxy_pass http://127.0.0.1:8000;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/test.shop.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.shop.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = test.shop.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name test.shop.com;
return 404; # managed by Certbot
}
您必須創建新的虛擬主機並將該虛擬主機監聽到端口 8080。
server {
listen 8080 ssl;
server_name test.shop.com;
root /var/www/html/test;
index index.html;
location /graphql/ {
proxy_pass http://127.0.0.1:8000;
}
ssl_certificate /etc/letsencrypt/live/test.shop.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.shop.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.