4 ms·
Has anyone had an experience of running websites from Go; or more specifically, how you handle none-HTML content? I've been considering porting my CMS from mod
by laumars 14y ago
Has anyone had an experience of running websites from Go; or more specifically, how you handle none-HTML content?
I've been considering porting my CMS from mod_perl to Go, but I'm not sure how you work with the other files (CSS et al). I did read somewhere that you run Go from Apache but it's not recommended.
- carbocation 14y agoI've just started creating toy projects in Go. I put these Go projects (and Apache, which runs older PHP projects) behind nginx. For hosting CSS, you either generate it programmatically and send the right Header, or you can use http.FileServe from the standard library [1]. (Surely other approaches are possible, but those are the two I've played with so far.) [1] https://code.google.com/p/go-wiki/wiki/HttpStaticFiles https://code.google.com/p/go-wiki/wiki/HttpStaticFiles
- laumars 14y agoThanks for that. The issue I have is that I would prefer to keep Apache around if I can (I have a few sites - some of which I host for friends). While my web server does have a few IPs attached, I'd rather not have to buy more IPs just to separate Apache from Go. And to be perfectly honest, I do quite like Apache. (each to their own I know, but I've had little reason to complain about it).
- carbocation 14y agoRight, you're describing my situation exactly. I used to run Apache solo. Now I run Nginx, which forwards requests to Apache or to my various go apps based on the domain name. Apache and the go apps just listen on different ports internally. The server only has 1 IP address.
- laumars 14y agoYou are an absolute star. If I could up vote you a hundred times I would. Thank you
- burntsushi 14y agoI use Apache too (it's all I've ever known), and run a few Go web apps. Everyone lives quite peacefully together. With Apache, I just set up a simple reverse proxy. Here's an example of one I use to run my own `godoc` server: <VirtualHost *:80> ServerAdmin admin@burntsushi.net ServerName godoc.burntsushi.net ProxyPreserveHost On ProxyPass / http://burntsushi.net:8080/ ProxyPassReverse / http://burntsushi.net:8080/ </VirtualHost>
- deleted 14y ago[deleted]
- laumars 14y agoNice idea. I might try that before dipping my toes into Nginx
- burntsushi 14y agoYeah, it's a nice holdover. I keep hearing great things about Nginx though. Someday I'll have time to check it out :-)
- Kiro 14y agoSeems very complicated. Why not just host the CSS files statically?
- genwin 14y agoMy website, niflet.com, is written in Go. It uses Go's web server. While in learning mode for Go I saw that others were using Nginx instead. Now that I've gone through the development process I can see why. Go's web server is basic. Things like compressing files, setting header values and other niceties you have to write yourself or look for code written by contributors [1]. It's not as bad as it sounds though. Go has a function for serving static files like CSS files, which I wrapped in a function to serve a zipped version if the client supports that. If I had it to do over again I would still use Go's web server, as it seems to work great. My site can conservatively handle 1 million page views hourly, using a cheap box. [1] https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/eVnTcMwNVjM https://groups.google.com/forum/?fromgroups=#!topic/golang-n...
- lateefj 14y agoI created a project for compression doing automatically doing compression and supporting a simple proxy system [1]. It is a pretty simple system but allow for dynamically doing proxy stuff and the compression is amazingly fast. I have found Go amazingly fast and stable. It being fun is just a bonus to code in. [1] https://bitbucket.org/lateefj/httphacks https://bitbucket.org/lateefj/httphacks