coreybutler / fenix

A simple and visual static web server with collaboration features.
https://preview.fenixwebserver.com
GNU General Public License v3.0
1.65k stars 135 forks source link

Ability to configure Fenix for Reverse Proxy #12

Open madhavraop opened 10 years ago

madhavraop commented 10 years ago

Is it possible to add reverse proxy feature in Fenix Server.

coreybutler commented 10 years ago

Possible? Yes, but I won't add that to Fenix... at least not the free version. I don't see much value in a reverse proxy for static web servers. The large majority of use cases for a reverse proxy are for naming, i.e. mydomain.local. To make that work, you also need DNS or a way to handle the host file. I am interested in adding support for local domains to Fenix, and I have a few ideas on how to do it... but I don't have time right now. If time allows, I could see it finding it's way into Fenix 3.0 though.

madhavraop commented 10 years ago

Thanks.

But it would be good for your to understand why I made this request on the first place.

Most of the static website built using AngularJS, KnockoutJS or Ember would require some form of service to be accessed to retrieve data. And there are technologies which are available to develop it. Many a time UI Developer are forced to have that setup on their machine in order to avoid cross-domain call. In case we can reverse proxy path of the calls to another server in same network - there is no need for developer to have that services deployed on his machine and he can have very light working environment.

Its useful for developer experience, and its pretty simple to implement using http-proxy https://www.npmjs.org/package/httpp-proxy module.

coreybutler commented 10 years ago

I understand your point, and I definitely see the development pain.

The only area I disagree with you is in how simple it would be to implement. http-proxy is not a drop-in solution. Like any reverse/forward proxy, there is still a dependency on DNS. A local DNS server would need to be running in Fenix, and the computer's network would need to be configured to use that DNS server before falling back to others. The alternative option of using the host file runs into user permission challenges... you'd be forced to run Fenix with an administrative account in order to save modifications to disk. Without domain resolution, network traffic won't even reach the proxy service.

coreybutler commented 10 years ago

I'm re-opening this since it's an enhancement request, not a current issue.

madhavraop commented 10 years ago

I will try to work on this and share my bits so that you include it in product

From: Corey Butler [mailto:notifications@github.com] Sent: Wednesday, May 7, 2014 1:27 PM To: coreybutler/fenix Cc: Madhavrao Pachupate Subject: Re: [fenix] Ability to configure Fenix for Reverse Proxy (#12)

I understand your point, and I definitely see the development pain.

The only area I disagree with you is in how simple it would be to implement. http-proxy is not a drop-in solution. Like any reverse/forward proxy, there is still a dependency on DNS. A local DNS server would need to be running in Fenix, and the computer's network would need to be configured to use that DNS server before falling back to others. The alternative option of using the host file runs into user permission challenges... you'd be forced to run Fenix with an administrative account in order to save modifications to disk. Without domain resolution, network traffic won't even reach the proxy service.

— Reply to this email directly or view it on GitHubhttps://github.com/coreybutler/fenix/issues/12#issuecomment-42464396.

coreybutler commented 10 years ago

It's a false presumption to think people even know they want to use a reverse proxy. I commonly hear "I just want to see http://mydomain.com in the browser". Fenix serves a larger audience than just developers, but even if it didn't, there are developers of all levels using it. Less experienced developers or designers may know how to write HTML/CSS/JS, but that doesn't mean they understand how proxying works. The bottom line is Fenix should be known as "Simple". It should abstract these kinds of complexities out of the every day workflow.

That said, DNS is the problem. Without it, you can't reach the reverse proxy. I'm not keen on the host file approach because it makes things messy. For example, if someone specifies "http://google.com" to point to a local Fenix server, but then needs to toggle it off so they can see the public site, it means the host file will need to be updated. That requires admin/root privileges while running the app to change it on the fly. The alternative is to embed a DNS server into Fenix. I currently favor this option, but there is still the problem of what happens with your DNS when Fenix isn't running (and therefore your Fenix DNS server isn't running). That would cause additional DNS overhead in everything you do online... though it could be negligible.

Bottom line is there needs to be more thought put into this. I already tried several options before releasing 2.0, but I have other projects I need to update before I can get to this feature. FWIW, it is a feature I'd like to see make it's way in someday though.

streaky commented 10 years ago

I realised you probably weren't up for it after I made my comment which is why deleted my comment. That said I totally realise there's potentially a DNS issue somewhere in the chain - my argument is that it might not be Fenix's issue to resolve. But hey it's your baby :)

mazondo commented 10 years ago

I agree fenix might not be the place for this. I built something to solve it for me. It's rough, but serves my purposes well enough. Requests that have local files serve files, those that don't are forwarded to the external service. Logs out request/responses to the console.

You can check it out at https://github.com/mazondo/passthrough

Thanks for fenix, been playing with it today and it's awesome!

coreybutler commented 10 years ago

@streaky - Didn't need to delete your comment... I thought it was valid. I've gone back and forth about whether DNS belongs in Fenix or not... but either way it is a problem I'm interested in solving at some point. Technically, it seems like it makes more sense in a separate background daemon (i.e. another companion project or something standalone), but from a workflow perspective it makes sense to be in Fenix. A fine line... :-)

@mazondo - Interesting idea with passthrough. I can see how that could be helpful. Thanks for sharing!