Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Apache reverse proxy location syntax maybe leads to errors #4841

Closed
dev4223 opened this issue Mar 8, 2019 · 5 comments
Closed

Apache reverse proxy location syntax maybe leads to errors #4841

dev4223 opened this issue Mar 8, 2019 · 5 comments
Labels
A-Docs things relating to the documentation

Comments

@dev4223
Copy link

dev4223 commented Mar 8, 2019

Description

I have a matrix synapse and mxisd installation on debian stretch working.
Only thing is, that I can't validate any email address. Email is sent but after clicking on the link i get the backend page with this message:

´´´
{"errcode":"M_NO_VALID_SESSION","error":"No valid session was found matching that sid and client secret","success":false}
´´´

Please read here kamax-matrix/mxisd#141

Version information

Debian Stretch

I've installed the lates matrix synapse package for debian stretch:
Package: matrix-synapse-py3
Version: 0.99.2+stretch1

and installed the latest stable mxisd package for stretch:
mxisd_1.3.1_all.deb

Solution

@pexus in kamax-matrix/mxisd#142 brought me to the Idea:
My apache config was

ProxyPreserveHost On
ProxyPass /_matrix/identity http://127.0.0.1:8090/_matrix/identity
ProxyPassReverse /_matrix/identity http://127.0.0.1:8090/_matrix/identity
<Location /_matrix>
  ProxyPass http://127.0.0.1:8008/_matrix nocanon
  ProxyPassReverse http://127.0.0.1:8008/_matrix
</Location>

Now I have changed it to

ProxyPreserveHost On
ProxyPass /_matrix/identity http://127.0.0.1:8090/_matrix/identity
ProxyPassReverse /_matrix/identity http://127.0.0.1:8090/_matrix/identity
ProxyPass /_matrix http://127.0.0.1:8008/_matrix nocanon
ProxyPassReverse /_matrix http://127.0.0.1:8008/_matrix

This solved the problem. This Location-syntax for synapse comes frome here https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.rst
And after the description here https://httpd.apache.org/docs/2.4/mod/core.html#location it seems not a good idea to do so.

@richvdh
Copy link
Member

richvdh commented Mar 11, 2019

Your problem was the mix of ProxyPass directives inside and outside Location directives.

The example came from #3783. @cwmke : was there a reason to prefer Location directives here?

@richvdh richvdh changed the title Apache reverse proxy location syntax maybe leeds to errors Apache reverse proxy location syntax maybe leads to errors Mar 11, 2019
@dev4223
Copy link
Author

dev4223 commented Mar 11, 2019

I came from the issue kamax-matrix/mxisd#141 and kamax-matrix/mxisd#142.
First try was to put the ProxyPass Directives both into different Location-Tags, one for /_matrix and one for /_matrix/identity. Then matrix identity didn't work so i tried it without Location syntax.
In matrix identity INSTALL readme it is put this way, in your readme for reverse_proxy it is with Location syntax. So I mixed it.
Last try was both without Location and it worked.

@cwmke
Copy link
Contributor

cwmke commented Mar 11, 2019

@richvdh no reason in particular. I was attempting to figure out how to get things working with apache and must have found an example that worked. From the linked documentation it sounds like location tags are an issue if the below is true.

This has several consequences. Most importantly, directives should not be used to control access to filesystem locations. Since several different URLs may map to the same filesystem location, such access controls may by circumvented.

@dev4223: your solution works well (just confirmed on my server.) I'll just submit a pull request to update the documentation using that syntax if that's agreeable?

@dev4223
Copy link
Author

dev4223 commented Mar 11, 2019

Oh yes, I'm glad I could help.

@neilisfragile neilisfragile added the A-Docs things relating to the documentation label Mar 12, 2019
richvdh pushed a commit that referenced this issue Mar 21, 2019
This one should close #4841. Many thanks to @dev4223 for bringing it up and finding a solution.

Signed-off-by: Colin White
@richvdh
Copy link
Member

richvdh commented Mar 21, 2019

fixed by #4870

@richvdh richvdh closed this as completed Mar 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Docs things relating to the documentation
Projects
None yet
Development

No branches or pull requests

4 participants