Last active
December 17, 2015 01:10
-
-
Save abackstrom/5526832 to your computer and use it in GitHub Desktop.
Lua-driven nginx config to make my website's SSL redirect work with App.net domain validation. App.net does not follow redirects during the validation process. This config ensures the validator gets a response code and body it understands.
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
# http->https redirect | |
server { | |
listen 207.192.74.235:80; | |
server_name sixohthree.com; | |
include logging.conf; | |
access_log /var/www/sixohthree.com/logs/access_log custom; | |
error_log /var/www/sixohthree.com/logs/error_log error; | |
location / { | |
content_by_lua ' | |
-- app.net doesn't follow my ssl redirect; make sure they get my rel=me link | |
if ngx.var.remote_addr == "204.124.19.120" then | |
ngx.say("<a href=https://alpha.app.net/abackstrom rel=me></a>") | |
end | |
'; | |
rewrite_by_lua ' | |
-- dont redirect app.net, they need content_by_lua | |
if ngx.var.remote_addr == "204.124.19.120" then | |
return | |
end | |
local url = "https://" .. ngx.var.host .. ngx.var.uri | |
if ngx.var.args ~= nil then | |
url = url .. "?" .. ngx.var.args | |
end | |
return ngx.redirect(url); | |
'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment