Apache 2.4反向代理HTTP到https不会重新发送cookie

时间:2018-12-12 15:00:27

标签: apache cookies https vhosts

经过数小时的测试,我无法在代理https后端的本地vhost上工作。

我从http://myhost-webapp.localhost-> https ://10.0.0.99:9443

工作

本地主机

    Define myhost myhost-webapp
    Define hostextension localhost
    Define DocumentRoot ${xampproot}/htdocs/myhost/webapp

    Define remotehost 10.0.0.99
    Define remoteport 9443
    <VirtualHost *:80>
        ServerAdmin ${myhost}@${hostextension}
        ServerName  ${myhost}.${hostextension}
        ServerAlias www.${myhost}.${hostextension} 

        DocumentRoot ${DocumentRoot}
        DirectoryIndex index.localhost.html index.php index.html index.htm

        SSLProxyEngine On
        SSLProxyVerify none 
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off
        SSLProxyCheckPeerExpire off
        #SSLCertificateFile      "conf/apache-selfsigned.crt"
        #SSLCertificateKeyFile "conf/apache-selfsigned.key"     
        RequestHeader set X-Forwarded-Proto "https"         
        Header add "Access-Control-Allow-Origin" "*"            

        ProxyPassReverseCookiePath / /
        ProxyPassReverseCookieDomain ${myhost}@${hostextension} ${remotehost}
        ProxyPass /rest/security https://${remotehost}:${remoteport}/rest/security
        ProxyPassReverse /rest/security https://${remotehost}:${remoteport}/rest/security
        ProxyPassMatch ^/rest/security(|[a-zA-Z0-9\-]+) https://${remotehost}:${remoteport}/rest/security/$1



        <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all      
        Require all granted         
        </Directory>

        ErrorLog  ${xampproot}/logs/${myhost}.${hostextension}.error.log
        CustomLog ${xampproot}/logs/${myhost}.${hostextension}.access.log combined
            </VirtualHost>  

第一个调用可以正常工作,因为它不能与cookie一起使用,但是登录后,所有后续调用都必须在请求中包含cookie。 对auth的调用工作正常,我在标头响应中获取了Cookie

标题登录响应

HTTP/1.1 200 OK
Date: Wed, 12 Dec 2018 14:32:09 GMT
Server: Apache/2.4.29 (Win32) OpenSSL/1.0.2n PHP/7.2.11
Content-Type: text/html; charset=UTF-8
Set-Cookie: a3u="AA8XiiVW3VSLw99k05LfcGjpKebdkuJba4532mb0N+MS8+xTD2+uHfhkNT+AYkemIb4CRXTNXedtLa6yXZwXWbc="; Path=/; Secure; HTTPOnly
Set-Cookie: a3pt="AMSQr9vTZhe38+XCCEIOfVmIoq3b22DAEOC8jvhDZtoTKNUfWNotT6GpbSRb1Ido5W7eK/51eFD2A3/+rAlt7mHpKH0SuNQ1BR2PmvlVpECl"; Path=/; Secure; HTTPOnly
Access-Control-Allow-Origin: *
Keep-Alive: timeout=5, max=59
Connection: Keep-Alive
Transfer-Encoding: chunked

成功登录后开始另一个呼叫,但这失败了,因为在我的标头请求中没有任何cookie

请求头错误

GET /rest/security/app-variables?_dc=1544625129496 HTTP/1.1
Host: myhost-webapp.localhost
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
X-Requested-With: XMLHttpRequest
Accept: */*
Referer: http://myhost-webapp.localhost/
Accept-Encoding: gzip, deflate, br
Accept-Language: it,en;q=0.9,en-US;q=0.8

在我的vhost本地https上一切正常,这是一个正确的请求标头(使用 https ://myhost-webapp.ssl.localhost

从HTTPS本地虚拟主机请求

GET /rest/security/app-variables?_dc=1544622599978 HTTP/1.1
Host: myhost-webapp.ssl.localhost
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
X-Requested-With: XMLHttpRequest
Accept: */*
Referer: https://myhost-webapp.ssl.localhost/
Accept-Encoding: gzip, deflate, br
Accept-Language: it,en;q=0.9,en-US;q=0.8
Cookie: JSESSIONID=sI01GSWEaSbhGD8mqUoY3w9b; a3u="AI4p0hyymcJPxd2Y13wtfsPpKebdkuJba4532mb0N+MS8+xTD2+uHfhkNT+AYkemISLeE/1iAS4UourleWCBNdQ="; a3pt="AC3FByfeyEpG60gWuA+vrtJKF16AS+FPtSRYeRh+AMl/XsBu6ODVQicgYWieM0jqOCLwC+8OKir+0alkmtYeVuQhuJSYnjUp2cVBC+EyCdqz"

为什么在我的http主机中不附加任何cookie?我的Cookie存储中没有任何已保存的信息。有人可以帮助我解决此配置吗?

我必须使用http,因为https vhost在Firefox和IE中不起作用,并且我必须在IE中测试我的应用程序网络:(

0 个答案:

没有答案