perusio / drupal-with-nginx

Running Drupal using nginx: an idiosyncratically crafted bleeding edge configuration.
855 stars 246 forks source link

Frontpage wont get cached #180

Open sgurlt opened 10 years ago

sgurlt commented 10 years ago

Hey,

I am actually trying to get nginx working with domain access. I am already using this configuration for one of my multisites and it works very good. For now I am stuck within a little problem, for some reason the frontpage of my Drupal site, that uses the Domain Access module (but I dont think that the module is the problem, cause even after deactivating it, the problem persists), wont get cached. Any other page gets cached without any problem, except the frontpage. Even when I change it to another node, that could be cached as long as it is not the frontpage, the page wont load when the apache service is stopped. I am using apache as my backend server.

After disabling the apache service, i recieve: 502 Bad Gateway and this is what I get in the logs:

2014/09/01 14:53:05 [error] 30442#0: *196 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.82.162, server: hessen.nginx.de, request: "GET / HTTP/1.1", upstream: "https://127.0.0.1:8445/", host: "hessen.nginx.de"

Any idea how to debug why the frontpage does not get cached? Even removing anything from it doesnt make nginx to write it into its cache ...

Greetings Sebastian

Update here is my config:

sites file:

## HTTPS server.
server {
    ## Comment the line below if you're using SPDY.
    listen 443 ssl;
    ## Uncomment the line below if you're using SPDY.
    #listen 443 ssl spdy;
    ## Replace the IPv6 address by your own address. The address below
    ## was stolen from the wikipedia page on IPv6.

    ## Comment the line below if you're using SPDY.
    #listen [::]:443 ssl ipv6only=on;
    ## Uncomment the line below if you're using SPDY.
    #listen [fe80::202:b3ff:fe1e:8330]:443 ssl spdy ipv6only=on;

    server_name example.nginx.de;

    limit_conn arbeit 32;

    ## Access and error logs.
    access_log /var/log/nginx/example.nginx.de_access.log;
    error_log /var/log/nginx/example.nginx.de_error.log;

    ## Keep alive timeout set to a greater value for SSL/TLS.
    keepalive_timeout 75 75;

    ## See the keepalive_timeout directive in nginx.conf.
    ## Server certificate and key.
    ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
    ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;

    ## Strict Transport Security header for enhanced security. See
    ## http://www.chromium.org/sts. I've set it to 2 hours; set it to
    ## whichever age you want.
    add_header Strict-Transport-Security "max-age=7200";

    root /srv/www/example_infoportal/www;
    index index.php;

    ## If you're using a Nginx version greater or equal to 1.1.4 then
    ## you can use keep alive connections to the upstream be it
    ## FastCGI or Apache. If that's not the case comment out the line below.
    fastcgi_keep_conn on; # keep alive to the FCGI upstream

    ## Uncomment if you're proxying to Apache for handling PHP.
    proxy_http_version 1.1; # keep alive to the Apache upstream

    ## See the blacklist.conf file at the parent dir: /etc/nginx.
    ## Deny access based on the User-Agent header.
    if ($bad_bot) {
        return 444;
    }
    ## Deny access based on the Referer header.
    if ($bad_referer) {
        return 444;
    }

    ## Protection against illegal HTTP methods. Out of the box only HEAD,
    ## GET and POST are allowed.
    if ($not_allowed_method) {
        return 405;
    }

set $nginx_proxy https://127.0.0.1:8445;

    ################################################################
    ### Generic configuration: for most Drupal 7 sites.
    ################################################################
    include apps/drupal/drupal.conf;

    ################################################################
    ### Configuration for Drupal 7 sites to serve URIs that need
    ### to be **escaped**
    ################################################################
    #include apps/drupal/drupal_escaped.conf;

    #################################################################
    ### Configuration for Drupal 7 sites that use boost.
    #################################################################
    #include apps/drupal/drupal_boost.conf;

    #################################################################
    ### Configuration for Drupal 7 sites that use boost if having
    ### to serve URIs that need to be **escaped**
    #################################################################
    #include apps/drupal/drupal_boost_escaped.conf;

    #################################################################
    ### Configuration for updating the site via update.php and running
    ### cron externally. If you don't use drush for running cron use
    ### the configuration below.
    #################################################################
    #include apps/drupal/drupal_cron_update.conf;

    ################################################################
    ### Installation handling. This should be commented out after
    ### installation if on an already installed site there's no need
    ### to touch it. If on a yet to be installed site. Uncomment the
    ### line below and comment out after installation. Note that
    ### there's a basic auth in front as secondary ligne of defense.
    ################################################################
    #include apps/drupal/drupal_install.conf;

    #################################################################
    ### Support for upload progress bar. Configurations differ for
    ### Drupal 6 and Drupal 7.
    #################################################################
    include apps/drupal/drupal_upload_progress.conf;

    ## Including the php-fpm status and ping pages config.
    ## Uncomment to enable if you're running php-fpm.
    #include php_fpm_status_vhost.conf;

    ## Including the Nginx stub status page for having stats about
    ## Nginx activity: http://wiki.nginx.org/HttpStubStatusModule.
    include nginx_status_vhost.conf;

} # HTTPS server

drupal.conf

location @drupal {
    ## Include the FastCGI config.
    #include apps/drupal/fastcgi_drupal.conf;
    #fastcgi_pass phpcgi;

    ## FastCGI microcache.
    #include apps/drupal/microcache_fcgi.conf;
    ## FCGI microcache for authenticated users also.
    #include apps/drupal/microcache_fcgi_auth.conf;

    ## If proxying to apache comment the two lines above and
    ## uncomment the two lines below.
    #proxy_pass http://phpapache/index.php?q=$uri;

    #proxy_pass $nginx_proxy/index.php?q=$uri;
    #proxy_pass $nginx_proxy/index.php;
    proxy_pass $nginx_proxy;

    proxy_set_header Connection '';
    ### force timeouts if one of backend is died ##
    #proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    ### Set headers ####
    proxy_set_header        Accept-Encoding   "";
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

    ### Most PHP, Python, Rails, Java App can use this header ###
    #proxy_set_header X-Forwarded-Proto https;##
    #This is better##
    proxy_set_header        X-Forwarded-Proto $scheme;
    add_header              Front-End-Https   on;

    ### By default we don't want to redirect it ####
    proxy_redirect     off;

    ## Proxy microcache.
    include apps/drupal/microcache_proxy.conf;
    ## Proxy microcache for authenticated users also.
    #include apps/drupal/microcache_proxy_auth.conf;

    ## Filefield Upload progress
    ## http://drupal.org/project/filefield_nginx_progress support
    ## through the NginxUploadProgress modules.
    #track_uploads uploads 60s;
}