configuration - nginx domain forwarding with added parameter -
i keep getting strange issue on nginx right now. have 2 nginx servers, 1 hosting content want forward other server. 1 doing forwarding has sites enabled config of:
server { listen 80; server_name pastdomain.com; return 301 https://domain.com$request_uri?from_past_domain=true; } server { listen 443; server_name pastdomain.com; return 301 https://domain.com$request_uri?from_past_domain=true; # bunch of ssl config here }
basically want send traffic new server can interpreted new variable from_past_domain can interpret needed on new server.
ie. pastdomain.com/thing/thing1/1/
would translate to
domain.com/thing/thing1/1?from_past_domain=true
right appears working except in case visit pastdomain.com
i instead domain.com//?from_past_domain=true
which incorrect. in addition, doesn't add new parameters correctly.
ie. if have pastdomain.com?test=1&test2=2 forwards domain.com/?test=1&test2=2?from_past_domain=true
how can go forwarding correctly?
you should use rewrite
if want change uri. in case nginx take care of correct request arguments.
also, use 1 server block http , https.
server { listen 80; listen 443 ssl; server_name pastdomain.com; rewrite ^(.*)$ https://domain.com$1?from_past_domain=true permanent; # bunch of ssl config here # not use `ssl on;` }
Comments
Post a Comment