Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: Nginx as proxy server |
|
Author |
|
ronnyj
Joined: 01 Oct 2014 Posts: 2
|
Posted: Wed 01 Oct '14 15:57 Post subject: Nginx as proxy server |
|
|
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: 7398 Location: EU, Germany, Next to Hamburg
|
|
Back to top |
|
ronnyj
Joined: 01 Oct 2014 Posts: 2
|
Posted: Thu 02 Oct '14 7:27 Post subject: |
|
|
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: 7398 Location: EU, Germany, Next to Hamburg
|
Posted: Thu 02 Oct '14 10:54 Post subject: |
|
|
Sorry I don't. I'm an apache person. |
|
Back to top |
|
|
|
|
|
|