unknown directive "if" nginx-0.7.60
Alan Hysinger
alanh at retailscience.com
Sun Jun 21 16:48:45 MSD 2009
Hi,
Please forgive my newbness to nginx here. I've tried a bunch of
stuff, googling and searching the nginx mail forum, to no avail.
I am trying to setup nginx using memcached and I have an app running
on an Apache backend. I need all POSTs passed through to the backend,
and GETs can be cached. I've read the examples, made up a .conf file,
and when I try to start nginx, I get this error:
----------------------------------------------------------------------------
[emerg]: unknown directive "if" in /home/mydomain/nginx/conf/
nginx.conf:26
----------------------------------------------------------------------------
If I comment out the if directive, then I get this error:
----------------------------------------------------------------------------
[emerg]: unknown directive "set" in /home/girlprops/nginx/conf/
nginx.conf:33
----------------------------------------------------------------------------
I want to add in here that with a different .conf, without trying to
use memcached, and just proxy_pass to my backend, things were working,
so I can demonstrate a little competency with nginx. It's when I
cobbled together .conf bits from various blogs about nginx+memcached
that I started having problems.
Running under Fedora Core 10, built from source. I figure I must not
be compiling some module in or I have my location {} block in the
wrong part of the .conf or some other n00b foolishness. If someone
can give me a pointer in the right direction, I'd appreciate it very
much. I'm pretty excited about being able to have a RAM resident
cache running on my site, and also being able to create a substantial
countermeasure against the latest DoS exploit by using nginx, not to
mention, getting a few gobs of RAM back from using Apache as the front
end.
Thank you for any help,
Alan
----------------------------------------------------------------------------
Here is my configure command:
----------------------------------------------------------------------------
./configure \
--prefix=/home/$1/nginx \
--user=$1 \
--group=$1 \
--without-http_rewrite_module \
--with-http_ssl_module \
--with-md5=/usr/include \
--with-http_realip_module \
--with-http_perl_module \
--with-pcre=../pcre-7.9 \
--with-sha1=/usr/include
----------------------------------------------------------------------------
and my nginx.conf
----------------------------------------------------------------------------
worker_processes 1;
events {
worker_connections 16384;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name home.mydomain.com home0.mydomain.com
home1.mydomain.com home2.mydomain.com home3.mydomain.com;
location / {
root html;
index index.html index.htm;
}
location /test {
if ($request_method != GET) {
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass http://127.0.0.1:9000;
break;
}
set $memcached_key "mydomain:$uri"
memcached_pass localhost:11212;
proxy_intercept_errors on;
error_page 404 @fetch;
}
location @fetch {
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass http://127.0.0.1:9000;
}
location /photos {
proxy_pass http://127.0.0.1:9002;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# HTTPS server
#
server {
listen 443;
server_name home.mydomain.com home0.mydomain.com
home1.mydomain.com home2.mydomain.com home3.mydomain.com;
ssl on;
ssl_certificate mydomain.com.cert;
ssl_certificate_key mydomain.com.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:
+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
location /MyApp {
proxy_pass http://127.0.0.1:9001;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
More information about the nginx
mailing list