Welcome! Log In Create A New Profile

Advanced

CORS with location rewrite

Posted by JackBlack 
CORS with location rewrite
March 16, 2017 09:14AM
Hi guys,

please help me to realize why nginx 1.8 returns 404 to subdomain page proxy_pass'ed to localhost:8088 when I try to enable CORS.


...

# main site conf
# commenting the following block makes subdomain page to be accessible again.
location / {
add_header 'Access-Control-Allow-Origin' https://subdomain.domain.extention;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}

if ($host ~* ^domain\.extention$) {
rewrite ^/subpage/ https://domain.extention/ permanent;
break;
}

...

#subdomain proxied by localhost:8088
location / {
proxy_pass https://127.0.0.1:8088/subpage/;
proxy_redirect https://127.0.0.1:8088/subpage/ /;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_ssl_session_reuse off;
}

Thanks in advance,
JB
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 260
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready