update config files deploy.
Some checks failed
Deploy / Build (push) Failing after 34s

This commit is contained in:
luocai 2024-11-20 14:55:56 +08:00
parent 30185e9ff1
commit abea92c348
10 changed files with 246 additions and 207 deletions

View File

@ -4,7 +4,7 @@ ObjCBlockIndentWidth: 4
IndentWidth: 4
TabWidth: 4
AccessModifierOffset: -4
ColumnLimit: 120
ColumnLimit: 130
#模板声明后换行
AlwaysBreakTemplateDeclarations: true

View File

@ -5,6 +5,7 @@ on:
paths:
- '**.cpp'
- '**.h'
- '**.conf'
jobs:
Build:
runs-on: [ubuntu-latest, ubuntu-24.04]
@ -59,6 +60,24 @@ jobs:
cp /tmp/HttpServer /root/Server/HttpServer
nohup /root/Server/HttpServer > /dev/null 2>&1 &
exit 0
- name: Copy openresty configuration files to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ vars.YUYUN_SERVER }}
username: ${{ vars.YUYUN_USER }}
password: ${{ secrets.SERVER_ROOT_PASSWORD }}
overwrite: true
strip_components: 1
source: Server/conf
target: /root/Server
- name: Restart openresty
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ vars.YUYUN_SERVER }}
username: ${{ vars.YUYUN_USER }}
password: ${{ secrets.SERVER_ROOT_PASSWORD }}
script: |
systemctl restart openresty.service
- name: Notify-End
if: ${{ always() }}
run: |

View File

@ -27,6 +27,7 @@ public:
BUILD_SETTING(std::string, Server, "0.0.0.0");
BUILD_SETTING(uint16_t, Port, 8081);
BUILD_SETTING(uint16_t, WtPort, 8082);
BUILD_SETTING(uint32_t, Threads, std::thread::hardware_concurrency());
BUILD_SETTING(std::string, DocumentRoot, ".");
BUILD_SETTING(std::string, Sqlte3Path, "database.sqlite");

View File

@ -15,6 +15,7 @@ types {
text/vnd.wap.wml wml;
text/x-component htc;
image/avif avif;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
@ -51,6 +52,7 @@ types {
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx;
application/vnd.wap.wmlc wmlc;
application/wasm wasm;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;

View File

@ -15,6 +15,7 @@ types {
text/vnd.wap.wml wml;
text/x-component htc;
image/avif avif;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
@ -51,6 +52,7 @@ types {
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx;
application/vnd.wap.wmlc wmlc;
application/wasm wasm;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;

View File

@ -26,7 +26,7 @@ http {
keepalive_timeout 65;
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;
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 application/text image/jpeg image/gif image/png;
# 定义一个限流区域,名称为 one大小为 10MB限速为每 5 分钟 5 次请求
limit_req_zone $binary_remote_addr zone=one:10m rate=3r/m;
@ -36,10 +36,14 @@ http {
server 127.0.0.1:8081;
}
upstream twikoo {
upstream wt {
server 127.0.0.1:8082;
}
upstream twikoo {
server 127.0.0.1:8083;
}
upstream frp_http_proxy {
server 127.0.0.1:8084;
}
@ -56,6 +60,10 @@ http {
server 127.0.0.1:8088;
}
upstream meilisearch {
server 127.0.0.1:7700;
}
upstream typesense {
server 127.0.0.1:8108;
}

View File

@ -31,10 +31,18 @@ location ^~ /api/v1/login {
content_by_lua_file lua/login.lua;
}
location ^~ /api/v1/search/ {
proxy_pass http://meilisearch/;
}
location ~ ^/api/v1/.*$ {
proxy_pass http://local;
}
location ~ ^/wt/.+$ {
proxy_pass http://wt;
}
location /freedom {
if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
return 404;
@ -62,6 +70,7 @@ location ~ ^/(gitea|v2)($|/) {
proxy_set_header Upgrade $http_upgrade;
# 这里强制修改 Host 为 gitea.amass.fun 只是为了frpc能够做url路由
proxy_set_header Host gitea.amass.fun;
# proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

View File

@ -101,7 +101,7 @@ int main(int argc, char const *argv[]) {
auto udpServer = std::make_shared<UdpServer>(application->ioContext());
auto mediaServer = std::make_shared<MediaServer>(554, false);
auto webApp = Singleton<WebApplication>::instance<Construct>();
auto webApp = Singleton<WebApplication>::instance<Construct>(application->getWtPort());
using namespace boost::asio::ip;
auto proxyAddress = make_address(application->getServer());

View File

@ -12,14 +12,15 @@
#include <Wt/Dbo/SqlConnectionPool.h>
#include <Wt/Dbo/backend/Sqlite3.h>
#include <Wt/WServer.h>
#include <format>
WebApplication::WebApplication() {
WebApplication::WebApplication(uint16_t port) {
try {
std::vector<std::string> args;
args.push_back("--approot=./build");
args.push_back("--docroot=./build");
args.push_back("--config=resources/wt_config.xml");
args.push_back("--http-listen=127.0.0.1:8855");
args.push_back(std::format("--http-listen=127.0.0.1:{}", port));
// --docroot=. --no-compression --http-listen 127.0.0.1:8855
initializeAuthenticationService();
@ -27,11 +28,9 @@ WebApplication::WebApplication() {
m_sqlConnectionPool = createConnectionPool(m_server->appRoot() + "database.sqlite");
m_server->addEntryPoint(Wt::EntryPointType::Application,
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false),
"/hello");
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false), "/hello");
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet,
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true),
"/wt/app.js");
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true), "/wt/app.js");
m_server->addResource(std::make_shared<AuthenticationResource>(*m_sqlConnectionPool), "/auth");
m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext");
m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db");
@ -45,8 +44,7 @@ WebApplication::WebApplication() {
std::unique_ptr<Wt::Dbo::SqlConnectionPool> WebApplication::createConnectionPool(const std::string &sqlite3) {
auto connection = std::make_unique<Wt::Dbo::backend::Sqlite3>(sqlite3);
connection->setProperty("show-queries", "true");
connection->setDateTimeStorage(Wt::Dbo::SqlDateTimeType::DateTime,
Wt::Dbo::backend::DateTimeStorage::PseudoISO8601AsText);
connection->setDateTimeStorage(Wt::Dbo::SqlDateTimeType::DateTime, Wt::Dbo::backend::DateTimeStorage::PseudoISO8601AsText);
return std::make_unique<Wt::Dbo::FixedSqlConnectionPool>(std::move(connection), 10);
}

View File

@ -31,7 +31,7 @@ public:
const Wt::Auth::PasswordService &passwordService();
protected:
WebApplication();
WebApplication(uint16_t port);
static std::unique_ptr<Wt::Dbo::SqlConnectionPool> createConnectionPool(const std::string &sqlite3);
std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment &env, bool embedded);