apache ProxyPassReverseCookiePath不能与远程cookie一起使用

时间:2016-06-20 13:46:56

标签: apache cookies

我希望在本地一个webapp中复制并在远程使用我的休息服务。登录后,远程服务器 domainB.com 创建一些cookie:

域名:domainB.com 路径:/

在我的apache服务器中我创建了这个vhost,但我可以使用远程休息服务,但没有cookie。 我该怎么办?

    Define myhost myapp-webapp
    Define hostextension localhost
    <VirtualHost *:80>
    ServerAdmin ${myhost}@${hostextension}
    ServerName  ${myhost}.${hostextension}
    ServerAlias www.${myhost}.${hostextension} 

    DocumentRoot C:/wamp/www/myapp/webapp

    #index.localhost.html è utile per le applicazione sencha su cui si vuole fare il bypass del cmd watch
    DirectoryIndex index.localhost.html index.php index.html index.htm

    #-------------------- rewrite rest + SSL ----------------------------------

    SSLProxyEngine On


    #https://dominioB.com/myapp-rest
    ProxyPass /myapp-rest https://dominioB.com/myapp-rest
    ProxyPassReverse /myapp-rest https://dominioB.com/myapp-rest

    ProxyPassMatch ^/myapp-rest(|[a-zA-Z0-9\-]+) https://dominioB.com/myapp-rest/$1



    #COOKIES
    #--------------------------------------
    ProxyPassReverseCookiePath / https://dominioB.com/
    ProxyPassReverseCookieDomain http://myapp-webapp.localhost/ https://dominioB.com/

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

    # Ricordarsi di creare la directory
    ErrorLog  C:/wamp/logs/${myhost}.${hostextension}.error.log
    CustomLog C:/wamp/logs/${myhost}.${hostextension}.access.log combined

    </VirtualHost>  

1 个答案:

答案 0 :(得分:0)

Se si cerca di connettersi a un sitocheèwithhttps che risponde con la richiesta di“sicurezza”comeflagèadidarioattiuvare in locale il servizio ssl del vostro vhost locale。

  1. 为您的apache wamp
  2. 创建一个新的证书密钥(请参阅Web上的教程)
  3. 在ssl(端口443)

    中创建新的vhost
    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #+++++++++++++++++ domaina.localhost +++++++++++++++++++++
    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Define myhost domaina
    Define hostextension localhost
    <VirtualHost *:443>
            ServerAdmin ${myhost}@${hostextension}
            ServerName  ${myhost}.${hostextension}
            ServerAlias www.${myhost}.${hostextension} 
    
            DocumentRoot C:/wamp/www/myapp/webapp
    
            #index.localhost.html è utile per le applicazione sencha su cui si vuole fare il bypass del cmd watch
            DirectoryIndex index.localhost.html index.php index.html index.htm
    
    
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            #+                                  SSL                                      +
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            # myapp work with ssl flag and we must send call from a ssl vhost
            # tutorial for install SSL in wamp https://www.youtube.com/watch?v=TH6evGKgy20
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    
            SSLProxyEngine On
            SSLCertificateFile "C:/wamp/bin/apache/apache2.4.9/conf/keys/certificate.crt"
            SSLCertificateKeyFile "C:/wamp/bin/apache/apache2.4.9/conf/keys/private.key"
            RequestHeader set X-Forwarded-Proto "https"
    
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            #+                                  COOKIES                                  +
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            # We must create and resend set-cookie in our rest comunications
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            ProxyPassReverseCookiePath / /
            ProxyPassReverseCookieDomain domaina.localhost domainb.com
            RequestHeader set X-Forwarded-Proto "https"
    
    
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            #+                              PROXY PASS                                   +
            #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
            #https://domainb.com/myapp-rest
            ProxyPass /myapp-rest https://domainb.com/myapp-rest
            ProxyPassReverse /myapp-rest https://domainb.com/myapp-rest
            Header add "Access-Control-Allow-Origin" "*"
            ProxyPassMatch ^/myapp-rest(|[a-zA-Z0-9\-]+) https://domainb.com/myapp-rest/$1
    
    
    
            <Directory />
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all              
            </Directory>
    
            # Ricordarsi di creare la directory
            ErrorLog  C:/wamp/logs/${myhost}.${hostextension}-ssl.error.log
            CustomLog C:/wamp/logs/${myhost}.${hostextension}-ssl.access.log combined
    
    </VirtualHost>