Rewrite nginx host and proxypass to squid Rewrite nginx host and proxypass to squid nginx nginx

Rewrite nginx host and proxypass to squid


301 redirect is exactly what nginx shall do with that rewrite rule: because you put $scheme://$subdub at the replacement part, nginx will do a 301, ignoring that "break" flag.

If the replacement string begins with http:// then the client will be redirected, and any further rewrite directives are terminated.

Are you trying to "rewrite" or "redirect"? If it's just for rewrite, you can remove that rewrite directive:

    rewrite ^ $scheme://$subdub break;

and it will work because your upstream server could rely on the HOST header to determine the traffic target (virtual hosting).

Also your host header sent to the upstream server is wrong. It should be

    proxy_set_header  Host $subdub;

$scheme should not be put in the Host header.