logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: Nginx as proxy server
Author
ronnyj



Joined: 01 Oct 2014
Posts: 2

PostPosted: Wed 01 Oct '14 15:57    Post subject: Nginx as proxy server Reply with quote

Hello,
I'm a newbie about web server configurations and I'm trying to set up nginx as a proxy caching server in front of apache on Centos, running PHP as FastCGI.
I'd like to cache static content and I've done a basic config but when I check the nginx cache folder it's always empty.
Please help me to sort this out:

nginx.conf
Code:
worker_processes 8;

worker_rlimit_nofile 40000;
error_log /var/log/nginx/error.log crit;

events {
        worker_connections 2048;
        multi_accept on;
        use epoll;
}

http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        access_log off;
        sendfile           on;
        tcp_nopush         on;
        tcp_nodelay        on;
        keepalive_timeout  10;

        proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=cache:60m max_size=1G;
        open_file_cache max=20000 inactive=60m;
        open_file_cache_valid 1m;
        open_file_cache_min_uses 1;
        open_file_cache_errors on;

        gzip on;
        gzip_static on;
        gzip_comp_level 3;
        gzip_min_length 1000;
        gzip_buffers 4 32k;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
        gzip_disable "MSIE [1-6]\.";

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


site enabled config:
Code:
server {
        listen   80;
        root /mywebsite;
        index index.php index.html;
       }

       location / {
                try_files $uri @proxy;
       }

       location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$ {
                proxy_cache          cache;
                proxy_cache_key      $host$uri$is_args$args;
                proxy_cache_valid    200 301 302 1d;
                expires      1d;
       }

       location @proxy {
                proxy_pass http://127.0.0.1:7080;
                include /etc/nginx/proxy.conf;
       }

       location ~* \.php$ {
                proxy_pass http://127.0.0.1:7080;
                include /etc/nginx/proxy.conf;
       }

}


Any idea?
I would also appreciate some tuning advices.
Thank you.
Ronny.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7298
Location: Germany, Next to Hamburg

PostPosted: Wed 01 Oct '14 18:11    Post subject: Reply with quote

You miss some stuff in the config to cache the static content. See http://www.nginxtips.com/how-to-configure-nginx-as-a-reverse-proxy-for-apache/ for an example
Back to top
ronnyj



Joined: 01 Oct 2014
Posts: 2

PostPosted: Thu 02 Oct '14 7:27    Post subject: Reply with quote

Hi James, I follow the guide step by step but it's still not caching.
Any idea?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7298
Location: Germany, Next to Hamburg

PostPosted: Thu 02 Oct '14 10:54    Post subject: Reply with quote

Sorry I don't. I'm an apache person.
Back to top


Reply to topic   Topic: Nginx as proxy server View previous topic :: View next topic
Post new topic   Forum Index -> Other Software