1. domain.com으로 들어오면 new-domain.com으로 redirect
server {
server_name domain.com;
return 301 http://new-domain.com$request_uri;
}
2. domain.com에서 특정 경로는 proxy 그 외는 new-domain.com으로 redirect
server {
server_name domain.com;
location /api {
proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '*';
proxy_pass http://api-domain.com/api;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_read_timeout 300;
proxy_intercept_errors on;
}
location / {
return 301 http://new-domain.com$request_uri;
}
}
728x90
'Web Server > NGINX' 카테고리의 다른 글
[NGINX] 구성 (0) | 2022.09.28 |
---|
댓글