Fix nginx conf
This commit is contained in:
parent
212d555b51
commit
9f7ce7ad15
@ -6,59 +6,25 @@ events {
|
||||
}
|
||||
|
||||
http {
|
||||
init_by_lua_block {
|
||||
require "routes"
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
|
||||
include mime.types;
|
||||
charset utf-8;
|
||||
|
||||
try_files $uri $uri/ $uri.html =404;
|
||||
|
||||
location = /posts {
|
||||
# rewrite ^ /posts/ last; # loads "/posts/"
|
||||
# rewrite ^ /posts/ break; # loads "/posts/index.html"
|
||||
rewrite_by_lua_block {
|
||||
local flag = { ["break"] = false };
|
||||
-- equivalent to `rewrite ^ /posts/ break;`
|
||||
ngx.req.set_uri("/posts/", flag["break"])
|
||||
}
|
||||
rewrite ^ /posts/ break;
|
||||
}
|
||||
|
||||
location = /posts/ {
|
||||
content_by_lua_block {
|
||||
return ngx.redirect("/posts", ngx.HTTP_MOVED_PERMANENTLY)
|
||||
}
|
||||
}
|
||||
|
||||
location /posts/ {
|
||||
rewrite_by_lua_block {
|
||||
local uri = ngx.re.sub(ngx.var.uri, "^/posts/(.*)", "$1", "o")
|
||||
-- ngx.req.set_uri(uri)
|
||||
local ext = string.match(uri, "[%w%-%_]+$")
|
||||
|
||||
ngx.say("request path " .. uri)
|
||||
|
||||
if ext == uri then
|
||||
ngx.say("no extension")
|
||||
else
|
||||
ngx.say("extension " .. ext)
|
||||
end
|
||||
|
||||
ngx.say(ngx.var.uri)
|
||||
}
|
||||
|
||||
# rewrite ^ /posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html break;
|
||||
location ~ ^/(.+)/$ {
|
||||
return 302 /$1;
|
||||
}
|
||||
|
||||
location /css {
|
||||
expires 1h;
|
||||
alias css;
|
||||
}
|
||||
|
||||
location /blah {
|
||||
rewrite ^/posts$ /posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user