GithubHelp home page GithubHelp logo

cugbaoyi / nameless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pkuhollow/nameless

0.0 1.0 0.0 265 KB

未名树洞 的Golang后端

Home Page: https://www.pkuhollow.com

License: GNU Affero General Public License v3.0

Go 90.62% HTML 9.38%

nameless's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.