Created
March 24, 2014 15:31
-
-
Save notsobad/9742534 to your computer and use it in GitHub Desktop.
Redirect all request to a server except static files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 ; | |
server_name 127.0.0.1; | |
client_header_timeout 60s; | |
client_body_timeout 30s; | |
send_timeout 60s; | |
#access_log /var/log/redirect.access_log redirect; | |
location / { | |
access_by_lua ' | |
local uri = ngx.var.uri | |
local method = ngx.req.get_method() | |
if not ngx.re.match(method,"^GET|POST$","oj") then | |
return ngx.exit(ngx.HTTP_NOT_ALLOWED) | |
end | |
if ngx.re.match(uri, "\.(jp?g|png|gif|bmp|ico|rar|zip|gz|flv|swf|js|css)$", "ioj") then | |
return ngx.exit(ngx.HTTP_NOT_FOUND) | |
end | |
return ngx.redirect("http://www.notsobad.me/?a=1", ngx.HTTP_MOVED_TEMPORARILY) | |
'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment