Permalink
Browse files

Optimized Apache vhost

  • Loading branch information...
1 parent 6e0afd8 commit d6b9a6d4b9d6cc8c0f1e83fc825ef32ba5c70bc3 @naholyr committed Jan 20, 2011
Showing with 23 additions and 11 deletions.
  1. +3 −0 conf/common.js
  2. +4 −2 lib/301.tl.js
  3. +16 −9 server/apache-vhost
View
@@ -12,11 +12,14 @@ exports.conf = {
ajax_allowed_hosts: '*', // '*' or list of authorized hosts like "http://mysite.com"
+ static_enabled: true, // Set it to false if static files are served by another server
+
view: {
helpers: {
site_name: '301 ✄ url Too Long',
host: '301.tl',
api_host: 'api.301.tl',
+ static_host:'static.301.tl',
site_title: 'shorten Too Long URLs'
},
dynamicHelpers: {
View
@@ -82,8 +82,10 @@ exports.start = function(app, conf, express, onReady) {
app.configure(function() {
// Static paths
- for (var i=0; i<exports.statics.length; i++) {
- app.use(express.staticProvider(exports.statics[i]));
+ if (conf.static_enabled) {
+ for (var i=0; i<exports.statics.length; i++) {
+ app.use(express.staticProvider(exports.statics[i]));
+ }
}
// Main configuration : routes of 301.tl
View
@@ -1,15 +1,22 @@
<VirtualHost *:80>
- ServerName mysite.domain
+ ServerName mysite.domain
- # Enable to work with RewriteMap instead of direct redirects
- # Tests are not very eloquent for now, but it seems this method has some issues with many concurrent connections
- #RewriteEngine On
- #RewriteMap longUrl "prg:/usr/local/bin/node /path/to/server/rewrite-map.js"
- #RewriteRule ^/([a-zA-Z0-9]+) ${longUrl:$1} [R]
+# Enable this to handle decoding using rewrite map feature, but tests do not reveal a good impact on performance
+# RewriteEngine On
+# RewriteMap longUrl "prg:/usr/local/bin/node /path/to/301.tl/server/rewrite-map.js"
+# RewriteRule ^/([a-zA-Z0-9]+) ${longUrl:$1} [R]
+
+ ErrorLog /var/log/apache2/301.tl-error.log
+ CustomLog /var/log/apache2/301.tl-access.log combined
+
+# Enable the 4 following lines if you want Apache to handle static elements himself, and proxy the other requests
+# You can set "static_enabled" to false if you choose this option
+# DocumentRoot /path/to/301.tl/public/
+# ProxyPass /css !
+# ProxyPass /js !
+# ProxyPass /img !
+ ProxyPass / http://127.0.0.1:8001/
- ProxyPass / http://127.0.0.1:3000/
- CustomLog /var/log/apache2/mysite.domain-access.log combined
- ErrorLog /var/log/apache2/mysite.domain-error.log
<Proxy *>
Allow from all
</Proxy>

0 comments on commit d6b9a6d

Please sign in to comment.