stop non-localhost HTTP access, define proxy for http requests
This commit is contained in:
parent
46b9369f3f
commit
27c2e98d0e
37
nginx.conf
37
nginx.conf
@ -1,5 +1,5 @@
|
||||
worker_processes ${{NUM_WORKERS}};
|
||||
error_log stderr notice;
|
||||
error_log stderr notice; # PROBLEM
|
||||
daemon on;
|
||||
pid logs/nginx.pid;
|
||||
|
||||
@ -8,19 +8,54 @@ events {
|
||||
}
|
||||
|
||||
http {
|
||||
charset UTF-8;
|
||||
include mime.types;
|
||||
|
||||
server_tokens off;
|
||||
|
||||
# blocking non-local requests
|
||||
geo $bad_client {
|
||||
default 1;
|
||||
127.0.0.1 0;
|
||||
}
|
||||
|
||||
server {
|
||||
listen ${{PORT}};
|
||||
lua_code_cache ${{CODE_CACHE}};
|
||||
|
||||
if ($bad_client) {
|
||||
return 301 https://${{DOMAIN}}/$request_uri; #permanent
|
||||
}
|
||||
|
||||
location / {
|
||||
default_type text/html;
|
||||
set $_url "";
|
||||
content_by_lua '
|
||||
require("lapis").serve("app")
|
||||
';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
alias static/;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user