Skip to content

pkuhollow/nameless

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thuhole-go-backend

Build Status License: AGPL v3 codebeat badge FOSSA Status

未名树洞的Golang后端。

安装方式

git clone https://github.com/thuhole/thuhole-go-backend
cd thuhole-go-backend

# (optional)upgrade all dependencies
go get -u ./...

# install packages
go install ./...

example.config.yml复制到config.yml之后修改参数即可运行。

当后端程序运行时编辑config.yml可以热加载,不需要重启程序。

执行go install ./...时会在$GOROOT/bin生成3个可执行文件:

  • treehole-services-api: /contents/*, /send/*, /edit/*的API服务
  • treehole-login-api: /security/*的API服务
  • treehole-fallback: 服务宕机时的错误提示程序

部署方式

除了编译出的3个可执行文件外,部署一个后端需要使用以下服务:

Nginx配置示例

⚠注意:出于安全考虑,此配置仅供参考,切勿用于生产环境。

img.thuhole.com.conf

server {
    listen 80;

    server_name img.thuhole.com;
    index index.html index.htm;

    root /path/to/images/folder/;

    location / {
        try_files $uri $uri/ =404;
    }
}

api.thuhole.com.conf

server {
    listen 80;

    server_name api.thuhole.com;
    index index.html index.htm;

    root /path/to/webhole/folder/;

    location / {
        try_files $uri $uri/ =404;
    }

    location /contents/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_pass http://127.0.0.1:8081;
        error_page 502 = @fallback;
    }

    location /send/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_pass http://127.0.0.1:8081;
        error_page 502 = @fallback;
    }

    location /edit/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_pass http://127.0.0.1:8081;
        error_page 502 = @fallback;
    }

    location /security/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_pass http://127.0.0.1:8080;
        error_page 502 = @fallback;
    }

    location @fallback {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_pass http://127.0.0.1:1234;
    }
}

License

AGPL v3

FOSSA Status

About

未名树洞 的Golang后端

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 90.9%
  • HTML 9.1%