www.impactteachers.com/teach에서 application.impactteachers/teach로 모든 트래픽을 리디렉션하려고 합니다.
이런 방식으로 우리의 신청서는 다음 URL에서도 액세스할 수 있습니다: www.impactteachers.com/teach/
이는 다음 규칙을 사용하여 현재 Apache 서버에서 잘 작동합니다.
ProxyRequests Off
ProxyPreserveHost On
<Proxy http://application.impactteachers.com:8080/teach/>
Order allow,deny
Allow from all
</Proxy>
ProxyPass /teach/ http://application.impactteachers.com:8080/teach/
ProxyPassReverse /teach/ http://application.impactteachers.com:8080/teach/
우리 사이트를 Nginx 서버로 마이그레이션하기 때문에 이 문서에 따라 새 규칙을 만들어야 합니다.Apache ProxyPassReverse용 Nginx 솔루션지금까지 여러분의 도움으로 현재 코드는 다음과 같습니다.
location /teach {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://application.impactteachers.com:8080/teach;
proxy_redirect default;
}
이것을 테스트했는데 여전히 동일한 404 오류가 표시됩니다.
답변1
다음과 같이 시도해 보세요.
upstream teach_backend {
server application.impactteachers.com:8080 fail_timeout=2s;
keepalive 32;
}
server {
listen 80;
server_name your_server_name.com;
location /teach {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://teach_backend/teach;
proxy_redirect http://teach_backend/teach /teach;
#proxy_redirect default;
#expires -1;
#add_header Cache-Control "private";
}
}