nginx使用配置反代某https网站

server {
listen 80;
listen [::]:80;
server_name [loc.xiu.ee](http://loc.xiu.ee/);
#SSL Configuration
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /ssl/loc.xiu.ee.crt;
ssl_certificate_key /ssl/loc.xiu.ee.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
# proxy to another site
location ~/ {
proxy_pass [https://hostloc.com](https://hostloc.com/);
proxy_set_header Host [hostloc.com](http://hostloc.com/);
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header referer [https://hostloc.com/$request_uri](https://hostloc.com/$request_uri);
proxy_set_header Accept-Encoding "";
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0";
sub_filter_types _;
sub_filter '<base href="_[_https://hostloc.com/_](https://hostloc.com/)_">' '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" type="text/css" href="_[_//cdn.jsdelivr.net/gh/lifespy/css-and-js-hub/css/responsive.css_](notion://cdn.jsdelivr.net/gh/lifespy/css-and-js-hub/css/responsive.css)_" />';
sub_filter '_[_hostloc.com_](http://hostloc.com/)_' '_[_loc.xiu.ee_](http://loc.xiu.ee/)_';
sub_filter '</body>' '<script src="_[_//cdn.jsdelivr.net/gh/lifespy/css-and-js-hub/js/polish.js_](notion://cdn.jsdelivr.net/gh/lifespy/css-and-js-hub/js/polish.js)_"></script></body>';
sub_filter_once off;
set $static_fileEJLfi5A0 0;
if ( $uri ~_ "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
set $static_fileEJLfi5A0 1;
expires 12h;
}
if ( $static_fileEJLfi5A0 = 0 )
{
add_header Cache-Control no-cache;
}
}
}

欢迎指出任何有错误或不够清晰的表达,可以在下面评论区评论。

×

喜欢就点赞,疼爱就打赏

//