
나는 여기에서 다른 많은 사후 솔루션을 시도하고 있었지만 아무도 내 문제를 해결하는 데 도움을 줄 수 없습니다. https가 있는 간단한 nginx 구성과 기본 경로가 있는 node.js 앱이 있고 /
하위 도메인의 경우 다른 경로가 있습니다 /api
. 올바르게 액세스할 수 있지만 mywebapp.com
액세스하려고 하면 api.mywebapp.com
"nginx에 오신 것을 환영합니다" 페이지로 리디렉션됩니다. api.mywebapp.com
내 서버 IP 주소를 가리키는 DNS 레코드가 있습니다 .
이것은 내 nginx 구성 블록입니다.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mywebapp.com;
# SSL
include /etc/letsencrypt/mycerts.conf;
include /etc/letsencrypt/options-ssl-nginx.conf;
# reverse proxy
location / {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name api.mywebapp.com;
# SSL
include /etc/letsencrypt/mycerts.conf;
include /etc/letsencrypt/options-ssl-nginx.conf;
location /api {
limit_req zone=mylimit;
proxy_pass http://localhost:8000/api;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_bypass $http_upgrade;
}
}
내가 무엇을 놓치고 있나요?
답변1
다음에 대해 프록시를 구성했습니다.
location /api {
# ...
}
따라서 로만 접근 가능합니다 https://api.mywebapp.com/api/
.
아마도 이것을 다음과 같이 바꾸고 싶을 것입니다.
location / {
proxy_pass http://localhost:8000/api; # <- keep this
# ...
}