Last active
March 12, 2019 12:30
-
-
Save neoshrew/2e8542fc04a1b0acc65bd2aa1e08620f to your computer and use it in GitHub Desktop.
nginx-wtf
This file contains hidden or 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 default_server; | |
location = /banana/ { | |
return 200 'this is a banana.\n'; | |
} | |
location / { | |
return 200 'not proxied.\n'; | |
} | |
} | |
server { | |
listen 81 default_server; | |
location = /banana/ { | |
proxy_pass http://localhost:82; | |
} | |
location / { | |
return 200 'not proxied.\n'; | |
} | |
} | |
server { | |
listen 82 default_server; | |
location / { | |
return 200 'Proxied.\n'; | |
} | |
} |
This file contains hidden or 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 -s localhost:8080/banana | |
not proxied. | |
$curl -s localhost:8080/banana/ | |
this is a banana. | |
$curl -s localhost:8081/banana | |
<html> | |
<head><title>301 Moved Permanently</title></head> | |
<body> | |
<center><h1>301 Moved Permanently</h1></center> | |
<hr><center>nginx/1.15.8</center> | |
</body> | |
</html> | |
$curl -sI localhost:8081/banana | |
HTTP/1.1 301 Moved Permanently | |
Server: nginx/1.15.8 | |
Date: Tue, 12 Mar 2019 12:29:09 GMT | |
Content-Type: text/html | |
Content-Length: 169 | |
Location: http://localhost:81/banana/ | |
Connection: keep-alive | |
$curl -s localhost:8081/banana/ | |
Proxied. |
This file contains hidden or 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
#!/usr/bin/env bash | |
docker run --rm -it \ | |
--name nginx-sucks \ | |
-p 8080:80 -p 8081:81 \ | |
-v $(pwd)/conf.d:/etc/nginx/conf.d \ | |
nginx:1.15.8-alpine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment