4 ms·
I'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 ge
by carbocation 14y ago
I'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?