Skip to content

Instantly share code, notes, and snippets.

@neoshrew
Last active March 12, 2019 12:30
Show Gist options
  • Save neoshrew/2e8542fc04a1b0acc65bd2aa1e08620f to your computer and use it in GitHub Desktop.
Save neoshrew/2e8542fc04a1b0acc65bd2aa1e08620f to your computer and use it in GitHub Desktop.
nginx-wtf
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';
}
}
$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.
#!/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