Add Emojis to NGINX HTTP Headers
Written: 2020/04/29
The idea to explore adding emojis into response headers came after reading the following Tweet by @elenalindq, specifically mentioning icanhazip.com, which at the time of writing has a duck emoji HTTP response header as ween below:
That lead me to locate other Tweets and posts about using emoji’s in NGINX headers, or HTTP headers as a whole. After some addtional digging I found that as long as the UTC-8 character set is enabled on the server, the use of emoji’s within the NGINX configuration file should work.
I eventually found an NGINX article covering the use of emoji’s within the NGINX configuration file at Introducing Full Emoji Support in NGINX and NGINX Plus Configuration. The article indicated copying the emoji in to the configuration file will allow it to be used in even more ways than just returning a header, such as adding them as comments within the NGINX configuration file.
I eventually found a good list of emoji’s to test within the configuration file and how they would look when being viewed via cURL in this case.
So far I have tested this on Ubuntu, OSX and OpenBSD using iTerm2 without issues and using Chrome’s Dev Tools to view headers too. I was able to open the NGINX configuration file using vim and the emoji was present. Parsing the configuration file also did not return any errors!
In order to set the actual header in the configuration file the following header can be used, just change the header name and the emoji to suit your needs:
The headers are more practical in terms of providing a quirk feature as opposed to a practical functionality. Definitely an interesting concept I will continue to explore.