Skip to content

Instantly share code, notes, and snippets.

@robbwagoner
Last active November 17, 2017 17:28
Show Gist options
  • Save robbwagoner/e11c09a046a82b28c12d8fa2200e6549 to your computer and use it in GitHub Desktop.
Save robbwagoner/e11c09a046a82b28c12d8fa2200e6549 to your computer and use it in GitHub Desktop.
nginx socket socat

From https://github.com/GhostGroup/infrastructure/pull/180

Header verification

Use socat to eavesdrop on the Nginx -> Unicorn socket-based comms.

ubuntu@ip-10-0-191-247:/etc/nginx/sites-enabled$ SOCK=/var/www/shared/.unicorn.sock                                                                                                                                                [49/144]
ubuntu@ip-10-0-191-247:/etc/nginx/sites-enabled$ sudo mv ${SOCK} ${SOCK}.ORIG
ubuntu@ip-10-0-191-247:/etc/nginx/sites-enabled$ sudo socat -t100 -v UNIX-LISTEN:${SOCK},mode=777,reuseaddr,fork   UNIX-CONNECT:${SOCK}.ORIG
> 2016/04/12 16:02:21.313206  length=321 from=0 to=320
GET /health HTTP/1.0\r
X-Request-Id: 27AC6564-EEE5-4DCF-B327-19563E3DC752\r  # UUID/Request-Id
X-Real-IP: 127.0.0.1\r
X-Forwarded-Host: localhost\r
X-Forwarded-Server: localhost\r
X-Forwarded-For: 127.0.0.1\r
X-Request-Start: t=1460476941.312\r
Host: localhost\r
Connection: close\r
User-Agent: curl/7.35.0\r
#!/bin/bash
SOCK=/var/www/shared/.unicorn.sock
sudo mv ${SOCK} ${SOCK}.ORIG
sudo socat -t100 -v UNIX-LISTEN:${SOCK},mode=777,reuseaddr,fork UNIX-CONNECT:${SOCK}.ORIG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment