逆天操作-将https访问通过反向代理转换成http访问

业务需求:第三方平台要求以https协议来访问网站,但平台没有配置https,只有http,如果不配置成https,第三方平台不提供服务。

解决方法:通过apache反向代理+浏览器跨域解决httpshttp问题

重点要解决以下两个问题:

                  1.浏览器只允许httpshttps的访问,不允许httpshttp的访问,解决方法是再做一次代理,通过另一个域名来做httpshttp的访问

                  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.htmdefault.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_ciphersECDHE-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]# cataaaaa.com-httpd-ssl-proxy.conf

 

ProxyRequests Off

 

<Proxy balancer://mis>

 

        BalancerMember  http://1.1.1.1:5110

         Orderdeny,allow

            Allow from all

         HeadersetAccess-Control-Allow-Origin https:// abc.abc.com

</Proxy>

 

 

 

#<Location /manager>

 

#SetHandler balancer-manager

 

#Order Deny,Allow

 

#Allow from all

 

#</Location>

 

 

 

#Listen 443

 

<VirtualHost _default_: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"

 

#<Files ~"\.(cgi|shtml|phtml|php3?)$">

#  SSLOptions +StdEnvVars

#</Files>

#<Directory"/var/www/cgi-bin">

#  SSLOptions +StdEnvVars

#</Directory>

 

<Directory"/www/wwwroot/default">

#   SSLOptions +StdEnvVars

#   AllowOverride All

#    Requireall granted

       Options FollowSymLinksExecCGI

       AllowOverride All

       Order allow,deny

       Allow from all

       Require all granted

</Directory>

 

#SetEnvIf User-Agent ".*MSIE.*" \

#       nokeepalivessl-unclean-shutdown \

#        downgrade-1.0force-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/

 

</VirtualHost>

 


分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS