业务需求:第三方平台要求以 https 协议来访问网站,但平台没有配置 https ,只有 http ,如果不配置成 https, 第三方平台不提供服务。
解决方法:通过 apache 反向代理 + 浏览器跨域解决 https 转 http 问题
重点要解决以下两个问题:
1. 浏览器只允许 https 到 https 的访问,不允许 https 到 http 的访问,解决方法是再做一次代理,通过另一个域名来做 https 到 http 的访问
2. 浏览器提示跨域问题,解决方法是通过代理的上面配置 origin
原访问流程图:
http://abc.com ( 前端页面 ) 调用后端接口( http://def.com/ )
修改后访问流程图:
https://abc.abc.com ( 前端页面 ) –> 调用反向代理的域名 https://aaaaa.com 这个域名再反向代理 http://def.com/
第一台服务器:前端 nginx https 配置环境:
[root@211501 nginx]# cat abc.com.conf
server
{
listen 80;
listen 443 ssl http2;
server_name abc.com;
index index.html index.htm default.php default.htm default.html;
root /www/wwwroot/abc.com;
#SSL-START SSL 相关配置,请勿删除或修改下一行带注释的 404 规则
#error_page 404/404.html;
ssl_certificate /etc/letsencrypt/live/abc.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/abc.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
error_page 404 /404.html;
error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP 引用配置,可以注释或修改
include enable-php-72.conf;
#PHP-INFO-END
#REWRITE-START URL 重写规则引用 , 修改后将导致面板设置的伪静态规则失效
include /www/server/panel/vhost/rewrite/abc.com.conf;
#REWRITE-END
# 禁止访问的文件或目录
location ~^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
# 一键申请 SSL 证书验证目录相关设置
location ~ \.well-known{
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log off;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
access_log off;
}
access_log /www/wwwlogs/abc.com.log;
error_log /www/wwwlogs/abc.com.error.log;
}
第二台服务器 Apache 反向代理配置:
[root@iZj6c7myadp30d01nd033yZextra]# cat aaaaa.com-httpd-ssl-proxy.conf
ProxyRequests Off
BalancerMember http://1.1.1.1:5110
Orderdeny,allow
Allow from all
Headerset Access-Control-Allow-Origin https:// abc.abc.com
#
#SetHandler balancer-manager
#Order Deny,Allow
#Allow from all
#
#Listen 443
DocumentRoot "/www/wwwroot/default"
ServerName aaaaa.com:443
ServerAlias *.aaaaa.com
ServerAdmin webmaster@example.com
ErrorLog logs/ abc _ssl_error_log
TransferLog logs/ abc _ssl_access_log
LogLevel warn
SSLEngine on
#SSLProtocol all -SSLv2
SSLProtocol all -SSLv2 -SSLv3
SSLStrictSNIVHostCheck off
SSLCipherSuiteAESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL
#SSLCipherSuiteDEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
SSLCertificateFile"/etc/pki/aaaaa.com/2279966_aaaaa.com_public.crt"
SSLCertificateKeyFile"/etc/pki/aaaaa.com/2279966_aaaaa.com.key"
SSLCertificateChainFile"/etc/pki/aaaaa.com/2279966_aaaaa.com_chain.crt"
#
# SSLOptions +StdEnvVars
#
#
# SSLOptions +StdEnvVars
#
# SSLOptions +StdEnvVars
# AllowOverride All
# Requireall granted
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
#SetEnvIf User-Agent ".*MSIE.*" \
# nokeepalive ssl-unclean-shutdown \
# downgrade-1.0 force-response-1.0
CustomLog logs/aaaaa.com_ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
RewriteEngine on
RewriteRule ^/(.*) balancer://mis/$1 [P]
ProxyPass / balancer://mis/
ProxyPassReverse / balancer://mis/
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- OpenAPI Generator 4.0.3 发布,使转换器公开访问
- JavaScript进阶系列-类型转换、隐式类型转换
- Android 多国语言转换 Excel 和 Excel 转换为 string
- [SSL证书转换(一)]关于JKS 转换成 CRT 和 KEY
- c++中几种常见的类型转换。int与string的转换,float与string的转换以及string和long类型之间的相互...
- Protocol Buffer使用转换工具将proto文件转换成Java文件流程及使用
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Design systems
Not all design systems are equally effective. Some can generate coherent user experiences, others produce confusing patchwork designs. Some inspire teams to contribute to them, others are neglected. S......一起来看看 《Design systems》 这本书的介绍吧!