bolinfest / plovr

plovr: a Closure build tool
78 stars 49 forks source link

add --base-url option to serve command, thus making it possible to place plovr behind a reverse proxy #26

Closed hblanks closed 5 years ago

hblanks commented 10 years ago

This updates CompilationServer's getServerForExchange() so that it can return a fixed base URL instead of re-constructing it from the referrer header in the request. In so doing, we make it possible to serve plovr from behind a reverse proxy. For instance, if your development server's nginx is configured with:

location /static/debug/plovr/ {
    proxy_pass http://localhost:9810/;
}

you may now configure plovr such that the URLs it generates are prefixed with http://localhost/static/debug/plovr/ by running:

java -jar plovr.jar serve \
    --base-url https://local.dev.foo.com/static/debug/plovr/ \
    plovr_config.json
hblanks commented 10 years ago

Hi! We've been using this patch for about six months and have found it quite useful. That said, it may be a bad idea, or the code may fail to follow conventions of which I am (sadly) rather ignorant. Please let me know what you think, and thanks much. -HJB

pauldraper commented 9 years ago

@bolinfest, that works in some cases, but --base-url is more general than that.

Proxies can serve on different protocols, hostnames, ports, and even base paths. Architectures vary. The OP serves everything from the same origin, and differentiates by the base path. So a request to https://local.dev.foo.com/static/debug/plovr/foo (Nginx) is forwarded to http://localhost:9810/foo (Plovr).

This sort of proxy option is fairly common among web servers.

gmalartre commented 9 years ago

@bolinfest referrer is not served in Adobe Phonegap (cordova) for instance. We end up with file being served through localhost when using the RAW option. Why not use the existing --listen option and drop the referrer approach?

atannus commented 7 years ago

Hi fellas.

I've hit a dead end trying to serve plovr over SSL. The --https flag does not work.

I really like this solution, and from what I've seen it should not be hard to resolve the conflict and accept the PR.

I did get Apache to proxy from https to http. But plovr still sends out URLs pointing to localhost:9810.

How are you guys handling using plovr over ssl these days? How do you get around this issue? What are the chances of accepting this neat little patch?

Thanks.

rgpower commented 7 years ago

Hi @atannus, et al,

I think an easier way would be to provide reverse proxy support is to enable plovr to understand the X-Forwarded-* family of headers and adjust host/port/proto accordingly. For example, see ~bolinfest/plovr/compare/master...rgpower:support_reverse_proxy.

Doing it this way, would enable you to run plovr behind your reverse proxy server without requiring special configuration entries or command line options.

If it pleases the plovr maintainers, I could submit at PR of this approach. Alternatively, @atannus you could try ~rgpower/plovr/tree/support_reverse_proxy

xvilo commented 5 years ago

Hi @all, is this still relevant? Maybe we can close it or discuss this in a (new) issue