[英]nginx reverse proxy all domains
i'm trying to reverse proxy any requested domain, my code works for specific domains only, for example:我正在尝试反向代理任何请求的域,我的代码仅适用于特定域,例如:
server {
listen 80;
server_name localhost;
location / {
rewrite_log on;
proxy_pass https://www.example.com;
}
}
this didn't work when http://localhost:80/www.example.com requested.这在http://localhost:80/www.example.com请求时不起作用。
location ~ ^/(.*)/ {
resolver 8.8.8.8;
proxy_pass http://$1;
}
nor this one也不是这个
location / {
resolver 8.8.8.8;
proxy_pass http://$http_host$uri$is_args$args;
}
this actually works , i didn't realize that because HTTPS websites doesn't work on it.这实际上有效,我没有意识到这是因为HTTPS 网站在它上面不起作用。
since HTTPS is the standard nowadays on almost any website, this may not worth it for everyone.由于 HTTPS 是当今几乎所有网站的标准,因此这对每个人来说可能都不值得。
server {
listen 80;
resolver 8.8.8.8;
location / {
proxy_pass http://$http_host;
proxy_set_header Host $http_host;
}
}
i couldn't find a solution for the HTTPS problem, it would be great to have that.我找不到HTTPS问题的解决方案,如果有这个解决方案就好了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.