Skip to content

Commit ed40494

Browse files
committed
use content_by_lua for production meta
1 parent 23e9626 commit ed40494

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

etc/nginx/localhost.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,23 @@ server {
5454
}
5555

5656
location ~ "^/(de|fr)/(?<hash>[0-9A-Z]{6})/?$" {
57+
# dev proxy vue
5758
include "/etc/nginx/conf.d/proxy_conf.inc";
5859
include "/etc/nginx/conf.d/proxy_meta.inc";
60+
61+
# prod
62+
#default_type "text/html; charset=utf-8";
63+
#content_by_lua_file "/etc/nginx/conf.d/meta_dist.lua";
5964
}
6065

6166
location ~ "^/(de|fr)/([0-9A-Z]{5})/(?<hash>[0-9A-Z]{6})/?$" {
67+
# dev proxy vue
6268
include "/etc/nginx/conf.d/proxy_conf.inc";
6369
include "/etc/nginx/conf.d/proxy_meta.inc";
70+
71+
# prod
72+
#default_type "text/html; charset=utf-8";
73+
#content_by_lua_file "/etc/nginx/conf.d/meta_dist.lua";
6474
}
6575

6676
location / {

etc/nginx/meta_dist.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
local file_meta, err = io.open("/var/services/django/media/snapshot-meta/" .. ngx.var.hash ..".html", "r")
2+
local file_app, err = io.open("/var/services/django/static/dist/app.html", "r")
3+
4+
local body = file_app:read("*all")
5+
6+
if file_meta then
7+
local meta_replace = file_meta:read("*all")
8+
body = body:gsub('<meta replace>', meta_replace)
9+
end
10+
11+
ngx.say(body)

etc/nginx/meta.lua renamed to etc/nginx/meta_proxy.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
local file_meta, err = io.open("/var/services/django/media/snapshot-meta/" .. ngx.var.hash ..".html", "r")
32
if file_meta then
43
local content = file_meta:read("*all")

etc/nginx/proxy_meta.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
header_filter_by_lua_block {
33
ngx.header.content_length = nil
44
}
5-
set_by_lua_file $meta "/etc/nginx/conf.d/meta.lua";
5+
set_by_lua_file $meta "/etc/nginx/conf.d/meta_proxy.lua";
66
body_filter_by_lua_block {
77
ngx.arg[1] = ngx.arg[1]:gsub('<meta replace>', ngx.var.meta)
88
}

0 commit comments

Comments
 (0)