apache2_nginx_反向代理设置_https_不验证后端证书_只允许访问首页

apache2_nginx_反向代理设置_https_不验证后端证书_只允许访问首页

转载注明来源: 本文链接 来自osnosn的博客,写于 2020-06-06.

apache2.4

  • apache 缺省就有 x-forwarded-for
<VirtualHost _default_:80>
ProxyPreserveHost On
<Location "/abc">
ProxyPass  http://10.22.33.44/abc
ProxyPassReverse  http://10.22.33.44/abc
</Location>
</VirtualHost>
#-----------------------------------
<VirtualHost _default_:443>
....(设置证书 server.key ,server.crt)
SSLProxyEngine On
ProxyPreserveHost On
SSLProxyVerify none
# 不验证后端服务器的证书
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
<Location "/abc">
ProxyPass  https://10.22.33.44/abc
ProxyPassReverse  https://10.22.33.44/abc
</Location>
</VirtualHost>

nginx

  • 反向代理设置中,要写上 x-forwarded-for 的配置
 location /abc/ {
    proxy_set_header   X-Forwarded-For   $remote_addr;
    proxy_set_header  Host  $host;
    proxy_pass    https://10.22.33.44;
    #proxy_pass    http://10.22.33.44;  #或者
 }

apache2.4 只允许访问首页

  • 如果你的缺省首页是 index.html
DocumentRoot "/xxxx/www"
<Directory "/xxxx/www/">
Require local
<Files "index.html"> #只允许访问首页
Require all granted
</Files>
</Directory>
<LocationMatch "^/$"> #只允许访问首页
Require all granted
</LocationMatch>

转载注明来源: 本文链接 来自osnosn的博客.

原文地址:https://www.cnblogs.com/osnosn/p/13057659.html