Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
130 lines (105 sloc) 3.45 KB
worker_processes ${{NUM_WORKERS}};
error_log ${{NOTICE_LOG}} notice;
daemon ${{DAEMON}};
events {
worker_connections 1024;
}
http {
include mime.types;
server {
client_max_body_size 15m;
listen ${{PORT}};
lua_code_cache ${{CODE_CACHE}};
location / {
if ($host = rocks.moonscript.org) {
rewrite ^/(?!api) $scheme://luarocks.org$request_uri permanent;
}
default_type text/html;
set $_url "";
content_by_lua "require('lapis').serve('app')";
}
location ~ /manifests/([^/]*)/(.+) {
default_type text/x-lua;
rewrite_by_lua_file "serve_file.lua";
resolver 8.8.8.8;
proxy_http_version 1.1;
proxy_hide_header 'Content-Type';
proxy_pass $_url;
}
location ~ ^/(?:dev/)?([^/]*?\.(?:rock|rockspec))$ {
default_type text/x-lua;
rewrite_by_lua_file "serve_file.lua";
resolver 8.8.8.8;
proxy_http_version 1.1;
proxy_pass $_url;
}
location /static/ {
access_log off;
gzip on;
gzip_types application/x-javascript text/css image/svg+xml;
alias static/;
}
location /favicon.ico {
alias static/favicon.ico;
}
location = /proxy {
internal;
rewrite_by_lua "
local req = ngx.req
for k,v in pairs(req.get_headers()) do
if k ~= 'content-length' then
req.clear_header(k)
end
end
if ngx.ctx.headers then
for k,v in pairs(ngx.ctx.headers) do
req.set_header(k, v)
end
end
";
resolver 8.8.8.8;
proxy_http_version 1.1;
proxy_pass $_url;
}
# redirect old luarocks wiki links to github
location ~ ^/en\b(?<wikipath>.*) {
rewrite_by_lua "
local path = ngx.var.wikipath:gsub('_', '-')
if ngx.var.args then
path = path .. '?' .. ngx.var.args
end
return ngx.redirect('https://github.com/luarocks/luarocks/wiki' .. path)
";
}
# redirect old luarocks repository links
location /repositories/ {
rewrite ^/repositories/rocks-scm$ https://luarocks.org//m/root/development-only permanent;
rewrite ^/repositories/rocks-scm(.+)$ https://luarocks.org/dev$1 permanent;
rewrite ^/repositories/rocks$ https://luarocks.org/m/root permanent;
rewrite ^/repositories/rocks(.+)$ https://luarocks.org$1 permanent;
}
# redirect old luarocks releases links
location /releases {
rewrite ^/releases(.*$) http://luarocks.github.io/luarocks/releases$1 redirect;
}
location /doc/history.pdf {
rewrite . http://hisham.hm/papers/muhammad_2013_history.pdf redirect;
}
}
# www redirect server
server {
listen ${{PORT}};
server_name ~^www\.(?<domain>.*)$;
location / {
rewrite ^ $scheme://$domain$request_uri permanent;
}
}
# # rocks.moonscript.org redirect server
# server {
# listen ${{PORT}};
# server_name rocks.moonscript.org;
# location / {
# rewrite ^ $scheme://luarocks.org$request_uri permanent;
# }
# }
}