Modify HttpServer default listen port.

This commit is contained in:
amass 2023-11-05 19:01:15 +08:00
parent 15024841d0
commit 51518e89e0
11 changed files with 239 additions and 7 deletions

View File

@ -30,7 +30,7 @@ http {
gzip on;
gzip_types application/octet-stream text/markdown text/plain application/json application/x-javascript text/css application/xml text/javascript application/javascript application/x-httpd-php image/jpeg image/gif image/png;
upstream local {
upstream twikoo {
server 127.0.0.1:8080;
}
@ -42,8 +42,8 @@ http {
server 127.0.0.1:8082;
}
upstream twikoo {
server 127.0.0.1:8089;
upstream local {
server 127.0.0.1:8083;
}
upstream drone_server {
@ -116,8 +116,8 @@ http {
listen 443 ssl;
server_name amass.fun;
ssl_certificate cert/6232035_amass.fun.pem;
ssl_certificate_key cert/6232035_amass.fun.key;
ssl_certificate cert/amass.fun.pem;
ssl_certificate_key cert/amass.fun.key;
ssl_session_timeout 5m; #缓存有效期
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议

24
Server/lua/access.lua Executable file
View File

@ -0,0 +1,24 @@
local session = require"resty.session".open()
if (string.find(ngx.var.location, "/video") ~= nil) then
if (session == nil or session.data.identify == nil) then
-- ngx.say("请先登陆");
ngx.exit(ngx.HTTP_FORBIDDEN);
end
end
for i, v in pairs(private_folder) do
if (string.find(ngx.var.location, "/blog/" .. v) ~= nil) then
if (session == nil or session.data.identify == nil) then
ngx.say("请先登陆");
-- ngx.exit(ngx.HTTP_FORBIDDEN);
end
end
end
-- if (ngx.var.location == "/blog/list") then
-- elseif (session == nil or session.data.identify == nil) then
-- ngx.say("请先登陆");
-- end

20
Server/lua/blog_list.lua Executable file
View File

@ -0,0 +1,20 @@
local cjson = require "cjson"
local session = require"resty.session".open()
if (session == nil or session.data.identify == nil) then
local chunk, eof = ngx.arg[1], ngx.arg[2];
local post_list = cjson.decode(chunk);
for i, v in pairs(private_folder) do
for dir, value in pairs(post_list) do
if (dir == v) then
post_list[dir] = nil;
end
end
end
ngx.arg[1] = cjson.encode(post_list);
ngx.arg[2] = true
else
end

14
Server/lua/helloworld.lua Executable file
View File

@ -0,0 +1,14 @@
ngx.log(ngx.ERR, "cookie a:", ngx.var.cookie_a)
ngx.header['Set-Cookie'] = {'a=32; path=/ ', 'b=4; path=/'}
ngx.header['Content-Type'] = "text/html; charset=utf-8";
local session = require"resty.session".start()
ngx.log(ngx.ERR, "cookie a:", ngx.var.cookie_a)
session.data.name = "OpenResty Fan"
session.cookie.path = "/123"
session:save()
ngx.say("<p>123Hello,world 中国</p>")

21
Server/lua/login.lua Executable file
View File

@ -0,0 +1,21 @@
local cjson = require "cjson"
ngx.req.read_body()
local body = ngx.req.get_body_data()
local json = cjson.decode(body)
local password = json["password"];
local result = {}
if (password == user_password) then
result.code = 0
result.message = "succuess"
local session = require"resty.session".start()
session.data.identify = "myself"
session.cookie.idletime = 120
session:save()
else
result.code = 1
result.message = "faliure"
end
ngx.say(cjson.encode(result));

20
Server/lua/profile.lua Executable file
View File

@ -0,0 +1,20 @@
local cjson = require "cjson"
local session = require"resty.session".open()
local response = {}
if (session == nil or session.data.identify == nil) then
response.code = 1
response.message = "未登录,session is nil."
ngx.say(cjson.encode(response));
return
else
if (session.data.identify ~= "myself") then
response.code = 1
response.message = "未登录,identify:" .. session.data.identify
else
response.code = 0
response.user = user_infomation
end
ngx.say(cjson.encode(response));
end

View File

@ -0,0 +1,6 @@
local cjson = require "cjson"
require "lua/website_collections"
ngx.log(ngx.ERR, "fsfsferror")
ngx.say(cjson.encode(website_collections));

9
Server/lua/settings.lua Executable file
View File

@ -0,0 +1,9 @@
private_folder = {"个人笔记"};
user_infomation = {
name = "Amass",
qq = "168062547",
phone = "15217052880",
user = user
};
user_password = "luo19961030";

View File

@ -0,0 +1,118 @@
website_collections = {
{
title = "参考手册",
websites = {
{
name = "GCC手册",
url = "https://gcc.gnu.org/onlinedocs/gcc",
newWindow = true
},
{
name = "POSIX API",
url = "https://pubs.opengroup.org/onlinepubs/9699919799.2018edition",
newWindow = true
},
{
name = "Boost Libraries",
url = "https://www.boost.org",
newWindow = true
},
{
name = "Material UI",
url = "https://material-ui.com",
newWindow = true
},
{
name = "C++参考手册",
url = "https://zh.cppreference.com",
newWindow = true
},
{
name = "Qt Blog",
url = "https://www.qt.io/blog",
newWindow = true
},
{
name = "Lua手册",
url = "https://www.lua.org/manual/5.4/manual.html",
newWindow = true
},
{
name = "x86 AT&T汇编",
favicon = "https://hackr.io/tutorials/assembly-language/logo-assembly-language.svg",
url = "https://flint.cs.yale.edu/cs421/papers/x86-asm/asm.html",
newWindow = true
},
{
name = "Using as",
url = "https://sourceware.org/binutils/docs/as/",
newWindow = true
},
{
name = "x86指令集参考",
favicon = "https://c9x.me/x86/icon/siyobik.ico",
url = "https://c9x.me/x86/",
newWindow = true
}
}
},
{
title = "工作学习",
websites = {
{
name = "Gitee",
url = "https://gitee.com",
newWindow = true
},
{
name = "LeetCode",
url = "https://leetcode-cn.com/problemset/all/?page=1&sort=DESCENDING&order=AC_RATE",
newWindow = true
},
{
name = "Google翻译",
favicon = "GTranslateIcon",
url = "https://translate.google.cn",
newWindow = true
},
{
name = "极客时间",
favicon = "http://static001.geekbang.org/static/time/icon/apple-touch-icon.jpg",
url = "https://time.geekbang.org",
newWindow = true
}
}
},
{
title = "娱乐",
websites = {
{
name = "哔哩哔哩",
url = "https://www.bilibili.com/",
newWindow = true
},
{
name = "动漫花园",
url = "http://share.dmhy.org",
newWindow = true
},
{
name = "片源网",
favicon = "MovieIcon",
url = "https://pianyuan.org",
newWindow = true
},
{
name = "射手网",
url = "https://assrt.net",
newWindow = true
},
{
name = "知轩藏书",
url = "http://zxcs.me/",
favicon = "http://zxcs.me/favicon.ico",
newWindow = true
}
}
}
}

View File

@ -164,7 +164,7 @@ void initSettings() {
ptree.put("server", "0.0.0.0");
}
if (ptree.find("port") == ptree.not_found()) {
ptree.put("port", 8080);
ptree.put("port", 8083);
}
if (ptree.find("docRoot") == ptree.not_found()) {
ptree.put("docRoot", ".");

View File

@ -38,7 +38,7 @@ function deploy_backend() {
fi
rsync -azv build/Server/HttpServer Server/conf root@amass.fun:${server_location}
ssh root@amass.fun "pkill HttpServer; source /etc/profile && \
nginx -p ${server_location} -s reload && \
openresty -p ${server_location} -s reload && \
cd ${server_location}; \
nohup ./HttpServer >logs/HttpServer.log 2>&1 &"
}