I am using nginx-lua module with redis to serve static files of ember-app. The index file content is stored in redis as a value which is being properly served by nginx when the (root) domain/IP is hit.
If login page is open from link, it gets opened properly. But when opened directly by hitting the url bar or refreshing the page the nginx gives 404 not found. The index file is in redis and rest of the files are being served from compiled js which is present on a CDN. Following is the nginx configuration
server
{
listen 80 ;
server_name 52.74.57.154;
root /;
default_type text/html;
location = / {
try_files $uri $uri/ /index.html?/$request_uri;
set_unescape_uri $key $arg_index_key;
set $fullkey 'ember-deploy-cli:index:${key}';
content_by_lua '
local redis = require "resty.redis"
local red = redis:new()
red:set_timeout(1000) -- 1 sec
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.say("failed to connect: ", err)
return
end
if ngx.var.key == "" then
--ngx.say("No Argument passed")
local res, err = red:get("ember-deploy-cli:index:current-content")
ngx.say(res)
return
end
local res, err = red:get(ngx.var.fullkey)
if res == ngx.null then
ngx.say("Key doesnt exist ")
return
end
ngx.say(res)
';
}
Aucun commentaire:
Enregistrer un commentaire