@Carl mentions this in his comment, so I'm going to indicate my process in the hope that it will be useful to you. These are the steps for Debian linux with nginx as the server.
- install
nginx with apt-get install nginx - create a file in
/etc/nginx/sites-available/your-app-name containing
.
server { listen 80; server_name your-app.com www.your-app.com your-app.ca; rewrite .*/favicon.ico /img/favicon.ico last; location ~ ^/(css|js|img|html)/ { root /path/to/your/static/resource/folder; expires 30d; } location / { proxy_pass http://localhost:3000; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } }
- restart the server using
/etc/init.d/nginx restart - run the Happstack app and make sure it is listening on port
3000 (or replace the corresponding port in location )
I use this tactic to deploy most of my web applications, with the exception of Erlang based ones; I trust Yaws to handle it myself. Apparently, some people view the same thing with warp , but I don't know enough about this to comment. The reverse proxy approach will work as long as the language you are working in can respond to HTTP requests, which is better than relying on (fast)?CGI or the corresponding mod_.*? .
Nginx is chosen as the server because itβs faster than the alternatives for serving static files (which pretty much does all this in this case), and because I find it very easy to configure. This preference is not the rule. You could probably use Apache or Lighttpd or something similar, but I will leave this explanation to someone who is more experienced with it.
source share