我正在RPi上运行我的家庭自动化系统(Domoticz),我最近将它放在代理后面,因此我可以通过HTTPS从Internet“安全”访问它。但是现在,授权cookie使得我很难通过HTTPS。
这是通过HTTP发生的事情:
Set-Cookie: DMZSID=randomJibberishOfWhichI'mNotSureIfIt'sSensitiveData; HttpOnly; path=/; Expires=Wed, 14 Aug 2019 15:27:23 GMT
Set-Cookie: DMZSID=none; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT
现在通过HTTPS:
在那之后,我遇到了各种各样的授权问题,并且在我手动删除该cookie之前,我基本上什么也做不了。
Domoticz在RPi上运行,该RPi也运行Apache。 Apache运行一个代理,该代理将globalURL.com/domoticz
转换为localIP:port
。
这可能是怎么回事? 我个人对从那时起,我了解了HttpOnly属性的含义。与我的问题无关。HttpOnly
标头中的Set-Cookie
部分非常感兴趣,因为它也存在于HTTPS调用中。
编辑:
设置cookie时看起来像path=/
,而不是删除cookie时,引起了问题。我不明白的是为什么当我不通过代理时这不是问题。可能是因为使用HTTPS时域是myExternalURL.com/domoticz/
,而不是myExternalURL.com
吗?
这是我正在使用的代理的Apache配置文件:
<VirtualHost *:443>
ServerName myExternalURL.com
ErrorLog ${APACHE_LOG_DIR}/port_443_error.log
CustomLog ${APACHE_LOG_DIR}/port_443_access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/myExternalURL.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/myExternalURL.com/privkey.pem
SSLProxyEngine on
ProxyPreserveHost On
ProxyRequests Off
RewriteEngine on
# I don't THINK the 3 lines below are important, since it's there for a
different web page, but I'll leave it in, in case it may mess with
something me knowing
# When Upgrade:websocket header is present, redirect to ws
# Using NC flag (case-insensitive) as some browsers will pass Websocket
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule .* ws://127.0.0.1:8000/socket.io%{REQUEST_URI} [P]
RewriteRule ^/domoticz$ /domoticz/ [R=307]
# The two lines below are for another web page
RewriteRule ^/sprinklers/node$ /sprinklers/node/ [R=307]
RewriteRule ^/sprinklers$ /sprinklers/ [R=307]
ProxyPassMatch /domoticz\/?(.*) https://127.0.0.1:444/$1
ProxyPassReverse /domoticz\/?(.*) https://127.0.0.1:444/$1
# The four lines below are for another web page
ProxyPassMatch /sprinklers/node(\/?)(.*) http://127.0.0.1:8000/$2
ProxyPassReverse /sprinklers/node(\/?)(.*) http://127.0.0.1:8000/$2
ProxyPassMatch /sprinklers(\/?)(.*) http://127.0.0.1:8091/$2
ProxyPassReverse /sprinklers(\/?)(.*) http://127.0.0.1:8091/$2
</VirtualHost>