client: using openresty for content rewriting
This commit is contained in:
parent
f96274033b
commit
b2800ad779
3 changed files with 45 additions and 4 deletions
|
@ -23,9 +23,10 @@ WORKDIR /var/www
|
||||||
COPY --from=builder /opt/app/public/ .
|
COPY --from=builder /opt/app/public/ .
|
||||||
|
|
||||||
|
|
||||||
FROM nginx:alpine as release
|
FROM openresty/openresty:alpine-fat as release
|
||||||
|
|
||||||
RUN apk --no-cache add dumb-init
|
RUN apk --no-cache add dumb-init
|
||||||
|
RUN /usr/local/openresty/luajit/bin/luarocks install gumbo
|
||||||
COPY --from=approot / /
|
COPY --from=approot / /
|
||||||
|
|
||||||
CMD ["/docker-start.sh"]
|
CMD ["/docker-start.sh"]
|
||||||
|
|
|
@ -8,4 +8,5 @@ sed -i "s|__BASEURL__|${BASE_URL:-/}|g" \
|
||||||
/var/www/manifest.json
|
/var/www/manifest.json
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
exec nginx
|
echo "$0 starting server..."
|
||||||
|
exec openresty -c /etc/nginx/nginx.conf
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
worker_processes 1;
|
worker_processes 1;
|
||||||
user nginx;
|
user nobody;
|
||||||
|
|
||||||
|
pcre_jit on;
|
||||||
|
|
||||||
error_log /dev/stderr warn;
|
error_log /dev/stderr warn;
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
@ -9,7 +11,7 @@ events {
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include /etc/nginx/mime.types;
|
include /usr/local/openresty/nginx/conf/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
||||||
log_format main '$remote_addr -> $request [$status] - '
|
log_format main '$remote_addr -> $request [$status] - '
|
||||||
|
@ -23,6 +25,11 @@ http {
|
||||||
server __BACKEND__:6666;
|
server __BACKEND__:6666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_by_lua_block {
|
||||||
|
cjson = require("cjson")
|
||||||
|
gumbo = require("gumbo")
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
|
|
||||||
|
@ -84,6 +91,38 @@ http {
|
||||||
gzip_proxied expired no-cache no-store private auth;
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location ~ ^/_internal_api/(.*)$ {
|
||||||
|
internal;
|
||||||
|
tcp_nodelay on;
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
|
||||||
|
gzip off;
|
||||||
|
proxy_connect_timeout 10s;
|
||||||
|
proxy_send_timeout 10s;
|
||||||
|
proxy_read_timeout 10s;
|
||||||
|
proxy_pass http://backend/$1;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/_internal_tag_generator/(.*)$ {
|
||||||
|
content_by_lua_block {
|
||||||
|
ngx.say("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
location /_og_tags_html {
|
||||||
|
root /var/www;
|
||||||
|
content_by_lua_block {
|
||||||
|
ngx.req.read_body()
|
||||||
|
|
||||||
|
local page_html = ngx.location.capture("/index.htm")
|
||||||
|
ngx.say(page_html.body)
|
||||||
|
|
||||||
|
ngx.req.set_header("Accept", "application/json")
|
||||||
|
local server_info = cjson.decode((ngx.location.capture("/_internal_api/info")).body)
|
||||||
|
ngx.say(server_info.config.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
location @unauthorized {
|
location @unauthorized {
|
||||||
return 403 "Unauthorized";
|
return 403 "Unauthorized";
|
||||||
default_type text/plain;
|
default_type text/plain;
|
||||||
|
|
Loading…
Reference in a new issue