Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure the app URL #36

Closed
thom4parisot opened this issue Nov 23, 2020 · 4 comments
Closed

Configure the app URL #36

thom4parisot opened this issue Nov 23, 2020 · 4 comments

Comments

@thom4parisot
Copy link

thom4parisot commented Nov 23, 2020

Given the following nginx configuration:

server {

	listen 80;

	location /copanier/ {
	  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	  proxy_set_header X-Forwarded-Proto $scheme;
	  proxy_set_header X-Real-IP $remote_addr;
	  proxy_set_header Host $http_host;
	  proxy_pass http:https://127.0.0.1:2244/;
	  proxy_redirect off;

 	}
}

When I go to http:https://localhost/copanier/, the app redirects me to http:https://localhost/connexion?next=/ — instead of the expected http:https://localhost/copanier/connexion?next=/.

I'm not yet sure where the problem happens, in the app itself, or Nginx.

@thom4parisot
Copy link
Author

Sounds like the prefix argument could be helpful to specify that the app URL is optionnally prefixed. I don't know if it works for other things than "static assets".

https://github.com/spiral-project/copanier/blob/10210272b680866e666cc51ee06178f518df2d7b/copanier/__init__.py#L37

- simple_server(app, port=2244)
+ from .. import config
+
+ simple_server(app, port=config.PORT || 2244, prefix=config.PREFIX || null)

Something like this?

@almet
Copy link
Owner

almet commented Nov 24, 2020

Hey, so it seems that the simple_server doesn't really have a concept of prefix as the static utility has.

So I believe we would have to fix this in the url_for helper where we could make it use an environment variable where the website URL is specified.

It might not be enough, as in some places the the "hostname" HTTP header is used to build the URL. Clearly not the way to go.

I'll try to have a look at this tomorrow :-)

@almet almet changed the title Redirect behind a reverse proxy seems to drop part of the URL Add a way to specify the app URL via configuration Nov 24, 2020
@almet almet changed the title Add a way to specify the app URL via configuration Configure the app URL via configuration Nov 24, 2020
@almet almet changed the title Configure the app URL via configuration Configure the app URL Nov 24, 2020
@almet
Copy link
Owner

almet commented Nov 24, 2020

This should be fixed with 6a9d944.

Did that worked for you?

@thom4parisot
Copy link
Author

It totally works!

Thank you so much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants