{"id":268005,"date":"2015-11-11T19:07:03","date_gmt":"2015-11-11T16:07:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=268005"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=268005","title":{"rendered":"Nginx + Lua + Redis. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u043e\u0442\u0434\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/adf\/e6d\/10e\/adfe6d10e2ec4c2a8f0631c45e7d5499.png\" alt=\"image\"\/><br \/>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0435 \u044f\u0437\u044b\u043a\u0438, \u043a\u0430\u043a <b>php<\/b>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0432\u044f\u0437\u043a\u0443 <b>nginx lua redis<\/b>, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443, \u0441\u043d\u044f\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0434\u0430\u0447\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0432 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0440\u0430\u0437.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c <b>nginx<\/b> \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c <b>nginx_lua_module.<\/b><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043a\u043e\u043c\u043f\u043b\u0438\u043b\u044f\u0442\u043e\u0440 <b>lua<\/b> (\u0432\u0435\u0440\u0441\u0438\u0438 2.0 \u0438\u043b\u0438 2.1)<\/p>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0435\u043c <a href=\"http:\/\/luajit.org\/download.html\">luaJit<\/a> \u0438 \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u0435\u0433\u043e  <\/p>\n<pre><code class=\"bash\">make && sudo make install <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 <b>nginx<\/b> \u0441 <b>nginx devel kit<\/b> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c <b>http_rewrite_module<\/b>, \u0430 \u0442\u043e\u0442 \u0441 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <b>pcre<\/b>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0435  <\/p>\n<pre><code class=\"bash\">sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev <\/code><\/pre>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0441\u0430\u043c <b>nginx<\/b><br \/>  <a href=\"https:\/\/github.com\/simpl\/ngx_devel_kit\/tags\">nginx devel kit <\/a><br \/>  <a href=\"https:\/\/github.com\/openresty\/lua-nginx-module\/tags\">nginx lua module<\/a> <br \/>  <a href=\"http:\/\/nginx.org\">nginx<\/a> <\/p>\n<p>  \u0421\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c <b>nginx<\/b>  <\/p>\n<pre><code class=\"bash\">export LUAJIT_LIB=\/usr\/local\/lib \/\/ \u043f\u0443\u0442\u044c \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 lua export LUAJIT_INC=\/usr\/local\/include\/luajit-2.1 \/\/\u043f\u0443\u0442\u044c \u043a luaJit  .\/configure  --prefix=\/etc\/nginx  --sbin-path=\/usr\/sbin\/nginx --conf-path=\/etc\/nginx\/nginx.conf  --error-log-path=\/var\/log\/nginx\/error.log --http-log-path=\/var\/log\/nginx\/access.log  --pid-path=\/var\/run\/nginx.pid  --lock-path=\/var\/run\/nginx.lock --http-client-body-temp-path=\/var\/cache\/nginx\/client_temp  --http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp  --http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp  --http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp --http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp  --user=nginx  --group=nginx   --with-ld-opt=&quot;-Wl,-rpath,\/path\/to\/lua\/lib&quot; \/\/ \u043f\u0443\u0442\u044c \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Lua --add-module=\/path\/to\/ngx_devel_kit \/\/\u043f\u0443\u0442\u044c \u043a nginx devel kit --add-module=\/path\/to\/lua-nginx-module \/\/ \u043f\u0443\u0442\u044c \u043a nginx lua module --without-http_gzip_module  make -j2 sudo make install <\/code><\/pre>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <b>lua<\/b> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <b>redis<\/b> <a href=\"https:\/\/github.com\/openresty\/lua-resty-redis\">lua redis lib<\/a> \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0435\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a <b>lua<\/b> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439  <\/p>\n<pre><code class=\"bash\">sudo make install <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <b>lua redis<\/b> \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <b>nginx<\/b><\/p>\n<pre><code class=\"bash\">http { ...     lua_package_path lua_package_path &quot;\/path\/to\/lib\/lua\/resty\/redis.lua;;&quot;; \/\/ \u043f\u0443\u0442\u044c \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 lua redis ... } <\/code><\/pre>\n<p>  \u0412\u0441\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u044b \u043d\u0430 <b>lua<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f <b>nginx<\/b>  <\/div>\n<\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0431\u044b\u0441\u0442\u043e \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043c\u044b \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0441\u0430\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0432 <b>redis<\/b> \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u0440\u0435\u0432\u0435 \u043a\u044d\u0448\u0430, \u0430 \u043c\u0435\u043d\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u044c \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443. \u041e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0448\u044c\u044e <b>lua<\/b> \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 <b>nginx<\/b>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c <b>php<\/b>, \u0447\u0442\u043e \u0432 \u0440\u0430\u0437\u044b\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442 \u0432\u044b\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c <b>Lua<\/b> \u0441\u043a\u0440\u0438\u043f\u0442<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">search.lua<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">local string = ngx.var.arg_string  -- \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0437 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0430 if string == nil then     ngx.exec(&quot;\/&quot;) -- \u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043d\u0435\u0442, \u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 end  local path = &quot;\/?string=&quot; .. string  local redis = require &quot;resty.redis&quot; -- \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 redis local red = redis:new()  red:set_timeout(1000) -- 1 sec  local ok, err = red:connect(&quot;127.0.0.1&quot;, 6379) if not ok then     ngx.exec(path) -- \u0435\u0441\u043b\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a redis, \u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 end  res, err = red:get(&quot;search:&quot; .. string); -- \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 redis  if res == ngx.null then     ngx.exec(path) -- \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0442, \u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 else     ngx.header.content_type = 'application\/json'     ngx.say(res) -- \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0435\u0441\u0442\u044c, \u0442\u043e \u043e\u0442\u0434\u0430\u0434\u0438\u043c \u0438\u0445 end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0432 nginx.conf \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c <b>nginx<\/b><\/p>\n<pre><code class=\"bash\">location \/search-by-string {    content_by_lua_file lua\/search.lua; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <b>\/search-by-string?string=smth<\/b> <b>lua<\/b> \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043a <b>redis<\/b> \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 <b>search:smth<\/b>. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <b>php<\/b>. \u041d\u043e \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u0437\u0430\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 <b>redis<\/b>, \u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043e\u0442\u0434\u0430\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p>  \u041d\u043e \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043c\u0435\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0440\u043e\u043b\u044c?<\/p>\n<p>  \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e \u0432 <b>redis<\/b> \u0438 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0441\u0435\u0441\u0441\u0438\u0438.<\/p>\n<p>  \u0422.\u043a. \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c <b>Symfony2<\/b>, \u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u0430\u043d\u0434\u043b <a href=\"https:\/\/github.com\/mrsuh\/nginx-session-handler\">nginx-session-handler<\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e \u0432 <b>redis<\/b> \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>  \u0412 <b>redis<\/b> \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0445\u044d\u0448 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<br \/>  <b>phpsession<\/b> \u2014 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u0441\u0435\u0441\u0441\u0438\u0438<br \/>  <b>php-session<\/b> \u2014 \u0441\u0430\u043c\u0430 \u0441\u0435\u0441\u0441\u0438\u044f php<br \/>  <b>user-role<\/b> \u2014 \u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c lua \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">session.lua<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">local redis = require &quot;resty.redis&quot; -- \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 redis local red = redis:new()  red:set_timeout(1000) -- 1 sec  local ok, err = red:connect(&quot;127.0.0.1&quot;, 6379) if not ok then     ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR) -- \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f,  end                                          --  \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c 500   local phpsession = ngx.var.cookie_PHPSESSID -- \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c id \u0441\u0435\u0441\u0441\u0438\u0438 \u0438\u0437 cookie \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f local ROLE_ADMIN = &quot;ROLE_ADMIN&quot; -- \u0440\u043e\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f  if phpsession == ngx.null then   ngx.exit(ngx.HTTP_FORBIDDEN) -- \u0435\u0441\u043b\u0438 \u0432 cookie \u043d\u0435\u0442 \u0441\u0435\u0441\u0441\u0438\u0438(\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d),  end                            -- \u0442\u043e  \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c 403  local res, err = red:hget(&quot;phpsession:&quot; .. phpsession, &quot;user-role&quot;) -- \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f                                                                      -- \u0438\u0437 redis \u043f\u043e id \u0441\u0435\u0441\u0441\u0438\u0438  if res == ngx.null or res ~= ROLE_ADMIN then      ngx.exit(ngx.HTTP_FORBIDDEN) -- \u0435\u0441\u043b\u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u043d\u0435\u0442(\u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0441\u0435\u0441\u0441\u0438\u0438) \u0438\u043b\u0438  end                              --  \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u0442\u0430 \u0440\u043e\u043b\u044c,  \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430,                                  -- \u0442\u043e  \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c 403 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u044b \u0434\u043e\u0441\u0442\u0430\u0435\u043c id \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 cookie, \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0435\u0433\u043e id \u0441\u0435\u0441\u0441\u0438\u0438 \u0438\u0437 <b>redis<\/b> \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 <b>HGET phpsession:id user-role<\/b>. \u0415\u0441\u043b\u0438 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0441\u0442\u0435\u043a\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0441\u0435\u0441\u0441\u0438\u0438, \u043e\u043d \u043d\u0435 \u0430\u0443\u0442\u0435\u043d\u0438\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d \u0438\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u043d\u0435 \u0440\u043e\u043b\u044c ROLE_ADMIN, \u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0435\u0440\u043d\u0435\u0442 \u043a\u043e\u0434 403.<\/p>\n<p>  \u0414\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441 \u0440\u043e\u043b\u044c\u044e ROLE_ADMIN.<\/p>\n<p>  \u041d\u0430 \u0434\u0435\u043b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 location <b>nginx<\/b>. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u043c\u044b \u0431\u0443\u0434\u0443\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0441\u0441\u0438\u0438.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">session.lua<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">local _M = {} --\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e  function _M.handle() -- \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u043d\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0432 \u043d\u0435\u0435 \u0432\u0435\u0441\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u043e\u0434      local redis = require &quot;resty.redis&quot;     local red = redis:new()      red:set_timeout(1000) -- 1 sec      local ok = red:connect(&quot;127.0.0.1&quot;, 6379)     if not ok then         ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)     end      local phpsession = ngx.var.cookie_PHPSESSID     local ROLE_ADMIN = &quot;ROLE_ADMIN&quot;      if phpsession == ngx.null then         ngx.exit(ngx.HTTP_FORBIDDEN)     end      local res = red:hget(&quot;phpsession:&quot; .. phpsession, &quot;user-role&quot;)      if res == ngx.null or res ~= ROLE_ADMIN then         ngx.exit(ngx.HTTP_FORBIDDEN)     end  end  return _M -- \u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c session.o \u0444\u0430\u0439\u043b \u0438\u0437 session.lua \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 <b>luaJit<\/b> \u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c <b>nginx<\/b> c \u044d\u0442\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<p>  \u0421\u043e\u0431\u0435\u0440\u0435\u043c session.o \u0444\u0430\u0439\u043b, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 <b>lua<\/b>  <\/p>\n<pre><code class=\"bash\">\/path\/to\/luajit\/bin\/luajit -bg session.lua session.o <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 <b>nginx<\/b> \u0441\u0442\u0440\u043e\u043a\u0443<\/p>\n<pre><code class=\"bash\">--with-ld-opt=&quot;\/path\/to\/session.o&quot; <\/code><\/pre>\n<p>  \u0438 \u0441\u043e\u0431\u0435\u0440\u0435\u043c <b>nginx<\/b>(\u043a\u0430\u043a \u0441\u043e\u0431\u0440\u0430\u0442\u044c nginx \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435)<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0432 \u043b\u044e\u0431\u043e\u0439 <b>lua<\/b> \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e handle() \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<pre><code class=\"bash\">local session = require &quot;session&quot; session.handle() <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430<\/b><\/p>\n<div class=\"spoiler_text\">Processor: Intel Xeon CPU X3440 @ 2.53GHz \u00d7 8 <br \/>  Memory: 7.9 GiB  <\/div>\n<\/div>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>php<\/b> \u0434\u043e\u0441\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 <b>redis<\/b> <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">ab -n 100 -c 100 php<\/b><\/p>\n<div class=\"spoiler_text\">Server Software: nginx\/1.9.4<\/p>\n<p>  Concurrency Level: 100<br \/>  Time taken for tests: 3.869 seconds<br \/>  Complete requests: 100<br \/>  Failed requests: 0<br \/>  <b>Requests per second: 25.85 [#\/sec] (mean)<\/b><br \/>  Time per request: 3868.776 [ms] (mean)<br \/>  Time per request: 38.688 [ms] (mean, across all concurrent requests)<br \/>  Transfer rate: 6.66 [Kbytes\/sec] received<\/p>\n<p>  Connection Times (ms)<br \/>   min mean[\u00b1sd] median max<br \/>  Connect: 1 3 1.1 3 5<br \/>  Processing: 155 2116 1053.7 2191 3863<br \/>  Waiting: 155 2116 1053.7 2191 3863<br \/>  Total: 160 2119 1052.6 2194 3864<\/p>\n<p>  Percentage of the requests served within a certain time (ms)<br \/>   50% 2194<br \/>   66% 2697<br \/>   75% 3015<br \/>   80% 3159<br \/>   90% 3504<br \/>   95% 3684<br \/>   98% 3861<br \/>   99% 3864<br \/>   100% 3864 (longest request)  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">ab -n 100 -c 100 lua<\/b><\/p>\n<div class=\"spoiler_text\">Server Software: nginx\/1.9.4<\/p>\n<p>  Concurrency Level: 100<br \/>  Time taken for tests: 0.022 seconds<br \/>  Complete requests: 100<br \/>  Failed requests: 0<br \/>  <b>Requests per second: 4549.59 [#\/sec] (mean)<\/b><br \/>  Time per request: 21.980 [ms] (mean)<br \/>  Time per request: 0.220 [ms] (mean, across all concurrent requests)<br \/>  Transfer rate: 688.66 [Kbytes\/sec] received<\/p>\n<p>  Connection Times (ms)<br \/>   min mean[\u00b1sd] median max<br \/>  Connect: 2 4 0.9 4 6<br \/>  Processing: 3 13 1.6 13 14<br \/>  Waiting: 3 13 1.6 13 14<br \/>  Total: 9 17 1.3 18 18<\/p>\n<p>  Percentage of the requests served within a certain time (ms)<br \/>   50% 18<br \/>   66% 18<br \/>   75% 18<br \/>   80% 18<br \/>   90% 18<br \/>   95% 18<br \/>   98% 18<br \/>   99% 18<br \/>   100% 18 (longest request)  <\/div>\n<\/div>\n<p>  \u041f\u043e \u044d\u0442\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u00ab\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443\u00bb \u0432 175 \u0440\u0430\u0437.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u0430. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u0436\u0435\u043b\u0430\u043d\u0438\u044f, \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u2014 \u043f\u0438\u0448\u0438\u0442\u0435.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/270463\/\"> http:\/\/habrahabr.ru\/post\/270463\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/adf\/e6d\/10e\/adfe6d10e2ec4c2a8f0631c45e7d5499.png\" alt=\"image\"\/><br \/>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0435 \u044f\u0437\u044b\u043a\u0438, \u043a\u0430\u043a <b>php<\/b>, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0432\u044f\u0437\u043a\u0443 <b>nginx lua redis<\/b>, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443, \u0441\u043d\u044f\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0434\u0430\u0447\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0432 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0440\u0430\u0437.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-268005","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=268005"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268005\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}