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 absolute and server URL prefixes #84

Closed
wants to merge 6 commits into from

Conversation

manics
Copy link
Member

@manics manics commented Jan 11, 2019

This started off as a fix for the X-Forwarded-Context X-ProxyContextPath. Previously they were always /proxy/{port}, now they should be /server-name if this is a managed server. Since this is related to the code that controls the URL rewriting I thought I'd add in support for absolute URLs.

I've done some testing with:

c.ServerProxy.servers = {
    'python-http': {
        'command': ['python3', '-m', 'http.server', '{port}'],
    },
    'python-http-abs': {
        'command': ['python3', '-m', 'http.server', '{port}'],
        'rewrite': '',
    },
}

python-http should produce logs like

"GET / HTTP/1.1" 200 -

python-http-abs should produce logs like

"GET /python-http-abs/ HTTP/1.1" 404 -

Also /proxy-abs/port is the absolute version of /proxy/port

Needs more testing! @jacobtomlinson @psychemedia

Closes #43

@manics
Copy link
Member Author

manics commented Jan 14, 2019

I've changed the config name from absolute: False|True to rewrite: "/"|"" to match the terminology typically used when configuring web-servers and proxies, e.g. https://github.com/kubernetes/ingress-nginx/tree/nginx-0.21.0/docs/examples/rewrite

The prefix for ports without rewriting is still /proxy-abs/port though alternatives could be /proxyp/{port} (for proxy-passthrough) or /passthrough/{port}. What do you think?

@yuvipanda
Copy link
Contributor

w00t, this is awesome. I'll try take a closer look later today.

Vague first thoughts:

  1. Are there ways we can do this without extra classes / inheritance?
  2. How about /proxy/absolute? That way we can do /proxy/<options-string> later if need be.

@manics
Copy link
Member Author

manics commented Jan 15, 2019

Are there ways we can do this without extra classes / inheritance?

Yes, I think it's possible to combine the classes and use a more complex URL match, I'll give it a go

How about /proxy/absolute

👍

Also changes the absolute proxy prefix to /proxy/absolute/
@manics manics closed this Jan 16, 2019
@manics manics deleted the proxy-base-urls branch January 16, 2019 18:05
@manics
Copy link
Member Author

manics commented Jan 16, 2019

Oops accidentally closed this .... reopened at #85

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

Successfully merging this pull request may close these issues.

Doesn't work with applications which use absolute URLs
2 participants