Last active
July 25, 2017 03:09
-
-
Save cnst/3521404dfdf5cb7b4c526b5c6dff38ff to your computer and use it in GitHub Desktop.
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
# Author: Constantine A. Murenin (cnst) http://cnst.su/ | |
# | |
# Automatically redirect `/search/?search=nginx` to `/search/nginx.html` externally, | |
# such that the location in the browser will change, but then process the request | |
# with the backend as if no such redirect has ever happened. | |
server { | |
listen [::]:7380; | |
location = /search/ { | |
if ($arg_search) { | |
return 302 /search/$arg_search.html; | |
} | |
default_type text/html; | |
return 200 | |
"<!DOCTYPE html><title>search</title> | |
<form><input name='search'/></form>\n"; | |
} | |
location /search/ { | |
rewrite ^/search/([^/]*)\.html$ /search/?search=$1 break; | |
proxy_pass http://localhost:7381; | |
} | |
location / { | |
return 403; | |
} | |
location = /45257380.nginx.conf { | |
default_type text/plain; | |
root /etc/nginx/conf.d; | |
} | |
} | |
server { | |
listen [::]:7381; | |
default_type text/plain; | |
return 200 | |
"$uri\n\t$is_args$args\n$request_uri\n"; | |
} |
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
% | |
% | |
%curl -v "localhost:7380/search/?search=test" | & fgrep -e Location -e title | |
< Location: http://localhost:7380/search/test.html | |
<head><title>302 Found</title></head> | |
% | |
% | |
%curl "localhost:7380/search/test.html" | |
/search/ | |
?search=test | |
/search/?search=test | |
% | |
% | |
% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment