Installing Horde on Nginx

Discussion in 'HOWTO-Related Questions' started by not_su, Sep 5, 2012.

  1. not_su

    not_su New Member

    My situation is somewhat similar to the one described in this thread - http://www.howtoforge.com/forums/showthread.php?t=58280 (How to replace Apache with Nginx on Horde installation?) and I've already followed the suggestions in the links the OP provided, plus some additional tweaking.

    My setup is a bit different insofar as I've tried to set up access to horde through a separate subdomain - i.e. horde.example.com. To this end, I created a separate file in /etc/nginx/sites-available/ and linked into sites-enabled and restarted nginx (plus everything else possible after each configuration I tried). I've also checked that horde.example.com is hitting the correct IP by running tracert. Perhaps the other difference is that I am running nginx behind varnish. Not sure if that has anything to do with it. That being said, I have (remarkably enough) configured Nagios to work using nagios.example.com and it seems to work just fine, so I suspect it isn't the varnish configuration.

    The error I get is rather odd. When I try to access horde.example.com, I just get the words "Access denied". Just that. No formatting, no error codes, no HTML, no script. Just the words. Even when I look at the source, that's all that I see.

    Anyway, some information that might assist:

    /etc/nginx/sites-available/horde

    Code:
    server {
        listen       8080;
        server_name  horde.example.com;
        root         /var/www/horde;
    	index 		 index.php;
    	
    	access_log  /var/log/nginx/horde.access.log;
    	error_log   /var/log/nginx/horde.error.log;
    	
    	location / {
    		# First attempt to serve request as file, then
    		# as directory, then fall back to index.html
    		try_files $uri $uri/ /index.php$args;
    	}
    	
    	location ~ \.php {
    		fastcgi_split_path_info ^(.+\.php)(/.+)$;
    		fastcgi_param PATH_INFO $fastcgi_path_info;
    		fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    		fastcgi_pass php5-fpm-sock;
    		fastcgi_index index.php;
    		# fastcgi_param HTTPS $php_https;
    		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    		include /etc/nginx/fastcgi_params;
    	}
    	
    	location /Microsoft-Server-ActiveSync {
    		alias /var/www/horde/rpc.php;
    		fastcgi_split_path_info ^(.+\.php)(/.+)$;
    		fastcgi_param PATH_INFO $fastcgi_path_info;
    		fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    		fastcgi_pass php5-fpm-sock;
    		fastcgi_index index.php;
    		# fastcgi_param HTTPS $php_https;
    		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    		include /etc/nginx/fastcgi_params;
    	}
    }
    I had to comment out "fastcgi_param HTTPS $php_https;" as it was throwing an error (not defined or something) and preventing nginx from running. I figured it wouldn't hurt as I'm not using https. I changed "fastcgi-pass" from 127.0.0.1:9000 from the other post to php5-fpm-sock as that is the value I had for the Nagios configuration which seemed to work. I think the rest is the same as described in the post referenced above.

    The horde.error.log is blank, while the horde.access.log didn't seem to be very helpful:

    Code:
    27.0.0.1 - - [04/Sep/2012:10:33:38 -0400] "GET / HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"
    127.0.0.1 - - [04/Sep/2012:10:33:38 -0400] "GET /favicon.ico HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"
    127.0.0.1 - - [04/Sep/2012:10:34:00 -0400] "GET / HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"
    127.0.0.1 - - [04/Sep/2012:10:34:01 -0400] "GET /favicon.ico HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"
    127.0.0.1 - - [04/Sep/2012:10:34:05 -0400] "GET /favicon.ico HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"
    127.0.0.1 - - [04/Sep/2012:17:47:27 -0400] "GET /test.php HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"
    127.0.0.1 - - [04/Sep/2012:17:47:28 -0400] "GET /favicon.ico HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"
    /etc/default/varnish is I think the standard Alternative 2:

    Code:
    DAEMON_OPTS="-a xxx.xxx.xxx.xxx:80 \
                 -T localhost:6082 \
                 -f /etc/varnish/wordpress.vcl \
                 -S /etc/varnish/secret \
                 -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
    While /etc/varnish/wordpress.vcl is as follows:

    Code:
    backend default {
        .host = "127.0.0.1";
        .port = "8080";
    }
    acl purge {
        "localhost";
    }
    sub vcl_recv {
        if (req.request == "PURGE") {
            if (!client.ip ~ purge) {
                error 405 "Not allowed.";
            }
            return(lookup);
        }
        if (req.url ~ "^/$") {
            unset req.http.cookie;
        }
    }
    sub vcl_hit {
        if (req.request == "PURGE") {
            set obj.ttl = 0s;
            error 200 "Purged.";
        }
    }
    sub vcl_miss {
        if (req.request == "PURGE") {
            error 404 "Not in cache.";
        }
        if (!(req.url ~ "wp-(login|admin)")) {
          unset req.http.cookie;
        }
        if (req.url ~ "^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$") {
            unset req.http.cookie;
            set req.url = regsub(req.url, "\?.$", "");
        }
        if (req.url ~ "^/$") {
            unset req.http.cookie;
        }
    }
    sub vcl_fetch {
        if (req.url ~ "^/$") {
            unset beresp.http.set-cookie;
        }
        if (!(req.url ~ "wp-(login|admin)")) {
            unset beresp.http.set-cookie;
        }
    }
    
    If anyone has any suggests, even if just to point me to where I might look, I'd appreciate it. I've tried to do what I can but am not sure where else to look next to figure this out.

    All of this is running on Ubuntu 12.04.
     

Share This Page