Skip to content

Commit 4af6fb5

Browse files
committed
First commit for open source
0 parents  commit 4af6fb5

File tree

11 files changed

+506
-0
lines changed

11 files changed

+506
-0
lines changed

.github/workflows/container.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: container build and push
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
tags: [ '*.*.*' ]
7+
pull_request:
8+
branches: [ "*" ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
EULIX_REGISTRY: ${{ secrets.EULIX_REGISTRY }}
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
17+
build:
18+
runs-on: [self-hosted, linux, x64]
19+
permissions:
20+
contents: read
21+
packages: write
22+
id-token: write
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
submodules: recursive
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v2
31+
32+
- name: Setup Docker buildx
33+
uses: docker/setup-buildx-action@v2
34+
35+
- name: Inspect builder
36+
run: |
37+
echo "Name: ${{ steps.buildx.outputs.name }}"
38+
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
39+
echo "Status: ${{ steps.buildx.outputs.status }}"
40+
echo "Flags: ${{ steps.buildx.outputs.flags }}"
41+
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
42+
43+
- name: Log into registry ${{ env.REGISTRY }}
44+
if: github.event_name != 'pull_request'
45+
uses: docker/login-action@v2
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Log into registry ${{ env.EULIX_REGISTRY }}
52+
if: github.event_name != 'pull_request'
53+
uses: docker/login-action@v2
54+
with:
55+
registry: ${{ env.EULIX_REGISTRY }}
56+
username: ${{ secrets.EULIX_REGISTRY_USERNAME }}
57+
password: ${{ secrets.EULIX_REGISTRY_PASSWORD }}
58+
59+
- name: Extract Docker metadata
60+
id: meta
61+
uses: docker/metadata-action@v2
62+
with:
63+
images: |
64+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
65+
${{ env.EULIX_REGISTRY }}/${{ env.IMAGE_NAME }}
66+
67+
- name: Build and push Docker image
68+
id: build-and-push
69+
uses: docker/build-push-action@v2
70+
with:
71+
context: .
72+
push: ${{ github.event_name != 'pull_request' }}
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
builder: ${{ steps.buildx.outputs.name }}
76+
platforms: linux/amd64,linux/arm64
77+
cache-from: type=gha
78+
cache-to: type=gha,mode=max
79+
file: Dockerfile

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.vscode

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
3+
## Version 1.0.1
4+
发布时间:2021.12.7
5+
- 支持从redis读取 network-server 访问地址并进行路由
6+
- 支持在转发头部添加指定字段
7+
8+
9+

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2022 Institute of Software Chinese Academy of Sciences (ISCAS)
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM openresty/openresty:1.21.4.1-4-bullseye-fat
16+
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf
17+
COPY ./conf/rewrite.lua /etc/nginx/conf.d/rewrite.lua
18+
COPY ./conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
19+
COPY entrypoint.sh /entrypoint.sh
20+
21+
RUN sed -i "s/deb.debian.org/mirrors.aliyun.com/g" /etc/apt/sources.list
22+
RUN apt update && apt install --no-install-recommends -y curl && rm -rf /var/lib/apt/lists/*
23+
RUN chmod +x /entrypoint.sh
24+
25+
ENV DOCKER_DNS=192.168.0.10
26+
27+
ENTRYPOINT ["/entrypoint.sh"]

NOTICE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--AOPlatform-Proxy--
2+
Copyright (c) 2022 Institute of Software, Chinese Academy of Sciences (ISCAS)
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
--Third Party Software Notices--
17+
AOPlatform-Proxy use software provided by third parties, including open source software. The following copyright statements and licenses apply to various components that are distributed with AOPlatform-Proxy. The AOPlatform-Proxy that includes this file does not necessarily use all of the third party software components referred to below.
18+
19+
Licensee must fully agree and comply with these license terms or must not use these components. The third party license terms apply only to the respective software to which the license pertains, and the third party license terms do not apply to the AOPlatform-Proxy.

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# platform proxy
2+
3+
English | [简体中文](./README_cn.md)
4+
5+
## Build And Run
6+
7+
### Compilation environment preparation
8+
9+
Please install the latest version of Docker.
10+
11+
### Source code download
12+
13+
You can download the entire project using the overall project download method, or you can download the repository of this module using the following command.
14+
15+
- Create a local directory , run cmd: `mkdir ./platform-proxy`
16+
- Enter the directory, run cmd: `cd ./platform-proxy`
17+
- Run cmd: `git clone git@github.com:ao-space/platform-proxy.git .`
18+
19+
### Container image building
20+
21+
Run cmd: `docker build -t hub.eulix.xyz/ao-space/platform-proxy:dev .` , Where the tag parameter can be modified according to the actual situation.。
22+
23+
### Environment variables
24+
25+
- REDIS_ADDR: redis server addr
26+
- REDIS_PORT: redis server port
27+
- REDIS_PASSWORD: redis access password
28+
29+
### Deploy
30+
31+
Run cmd: `docker run -itd --name platform-proxy -p 8001:80 -e REDIS_ADDR=192.168.10.155 -e REDIS_PORT=19462 -e REDIS_PASSWORD=EV8RYxWgEdVTwuyL hub.eulix.xyz/ao-space/platform-proxy:dev`
32+
33+
## Contribution Guidelines
34+
35+
Contributions to this project are very welcome. Here are some guidelines and suggestions to help you get involved in the project.
36+
37+
[Contribution Guidelines](https://github.com/ao-space/ao.space/blob/dev/docs/en/contribution-guidelines.md)
38+
39+
## Contact us
40+
41+
- Email: <developer@ao.space>
42+
- [Official Website](https://ao.space)
43+
- [Discussion group](https://slack.ao.space)

README_cn.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# platform proxy
2+
3+
[English](README.md) | 简体中文
4+
5+
## 构建和部署
6+
7+
### 构建环境准备
8+
9+
请安装最新版本的 docker 。
10+
11+
### 源码下载
12+
13+
可以通过整体项目源码下载的方式,或通过以下方式:
14+
15+
- 创建本地目录,执行命令: `mkdir ./platform-proxy`
16+
- 进入本地目录,执行命令: `cd ./platform-proxy`
17+
- 下载源码,执行命令: `git clone git@github.com:ao-space/platform-proxy.git .`
18+
19+
### 镜像构建
20+
21+
执行命令: `docker build -t hub.eulix.xyz/ao-space/platform-proxy:dev .` , tag 参数可以根据实际情况修改。
22+
23+
### 环境变量
24+
25+
- REDIS_ADDR: redis 服务器地址
26+
- REDIS_PORT: redis 服务器端口
27+
- REDIS_PASSWORD: redis 访问密码
28+
29+
### 部署服务
30+
31+
执行命令: `docker run -itd --name platform-proxy -p 8001:80 -e REDIS_ADDR=192.168.10.155 -e REDIS_PORT=19462 -e REDIS_PASSWORD=EV8RYxWgEdVTwuyL hub.eulix.xyz/ao-space/platform-proxy:dev`
32+
33+
## 贡献指南
34+
35+
我们非常欢迎对本项目进行贡献。以下是一些指导原则和建议,希望能够帮助您参与到项目中来。
36+
37+
[贡献指南](https://github.com/ao-space/ao.space/blob/dev/docs/cn/contribution-guidelines.md)
38+
39+
## 联系我们
40+
41+
- 邮箱:<developer@ao.space>
42+
- [官方网站](https://ao.space)
43+
- [讨论组](https://slack.ao.space)

conf/default.conf

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# nginx.vh.default.conf -- docker-openresty
2+
#
3+
# This file is installed to:
4+
# `/etc/nginx/conf.d/default.conf`
5+
#
6+
# It tracks the `server` section of the upstream OpenResty's `nginx.conf`.
7+
#
8+
# This config (and any other configs in `etc/nginx/conf.d/`) is loaded by
9+
# default by the `include` directive in `/usr/local/openresty/nginx/conf/nginx.conf`.
10+
#
11+
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
12+
#
13+
14+
lua_package_path "/opt/openresty/lualib/lua-resty-redis/lib/?.lua;;";
15+
16+
17+
server {
18+
listen 80;
19+
server_name localhost;
20+
set_by_lua $redis_addr 'return os.getenv("REDIS_ADDR")';
21+
set_by_lua $redis_port 'return os.getenv("REDIS_PORT")';
22+
set_by_lua $redis_password 'return os.getenv("REDIS_PASSWORD")';
23+
24+
#charset koi8-r;
25+
#access_log /var/log/nginx/host.access.log main;
26+
27+
#error_page 404 /404.html;
28+
29+
# redirect server error pages to the static page /50x.html
30+
#
31+
error_page 500 502 503 504 /50x.html;
32+
location = /50x.html {
33+
root /usr/local/openresty/nginx/html;
34+
}
35+
36+
location /healthcheck {
37+
default_type text/plain;
38+
return 200 "access success";
39+
}
40+
41+
# 以 / 开头的转发到 box
42+
location / {
43+
set $target '';
44+
set $clientid '' ;
45+
46+
rewrite_by_lua_file "/etc/nginx/conf.d/rewrite.lua" ;
47+
48+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
49+
proxy_set_header EID $clientid;
50+
proxy_set_header Network-Server-Addr $target;
51+
proxy_set_header Host $http_host;
52+
proxy_pass http://$target;
53+
}
54+
}

conf/nginx.conf

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# nginx.conf -- docker-openresty
2+
#
3+
# This file is installed to:
4+
# `/usr/local/openresty/nginx/conf/nginx.conf`
5+
# and is the file loaded by nginx at startup,
6+
# unless the user specifies otherwise.
7+
#
8+
# It tracks the upstream OpenResty's `nginx.conf`, but removes the `server`
9+
# section and adds this directive:
10+
# `include /etc/nginx/conf.d/*.conf;`
11+
#
12+
# The `docker-openresty` file `nginx.vh.default.conf` is copied to
13+
# `/etc/nginx/conf.d/default.conf`. It contains the `server section
14+
# of the upstream `nginx.conf`.
15+
#
16+
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
17+
#
18+
19+
#user nobody;
20+
#worker_processes 1;
21+
22+
# Enables the use of JIT for regular expressions to speed-up their processing.
23+
pcre_jit on;
24+
25+
26+
27+
#error_log logs/error.log;
28+
#error_log logs/error.log notice;
29+
#error_log logs/error.log info;
30+
31+
#pid logs/nginx.pid;
32+
33+
34+
events {
35+
worker_connections 65535;
36+
}
37+
38+
env REDIS_ADDR;
39+
env REDIS_PORT;
40+
env REDIS_PASSWORD;
41+
42+
http {
43+
include mime.types;
44+
default_type application/octet-stream;
45+
resolver <resolver> valid=30s ipv6=off;
46+
#resolver 192.168.10.1 valid=30s ipv6=off;
47+
48+
# Enables or disables the use of underscores in client request header fields.
49+
# When the use of underscores is disabled, request header fields whose names contain underscores are marked as invalid and become subject to the ignore_invalid_headers directive.
50+
# underscores_in_headers off;
51+
log_format main '$remote_addr - $remote_user [$time_local] [$http_host] "$request" '
52+
'$status $body_bytes_sent request_time:$request_time response_time:$upstream_response_time "$http_referer" "$http_bp_network_server" "$http_bp_forward_client_id" '
53+
'"$http_user_agent" "$http_x_forwarded_for" request-id:"$http_request_id" cookie_client_uuid:"$cookie_client_uuid" ';
54+
55+
access_log logs/access.log main;
56+
error_log logs/error.log info;
57+
58+
# Log in JSON Format
59+
# log_format nginxlog_json escape=json '{ "timestamp": "$time_iso8601", '
60+
# '"remote_addr": "$remote_addr", '
61+
# '"body_bytes_sent": $body_bytes_sent, '
62+
# '"request_time": $request_time, '
63+
# '"response_status": $status, '
64+
# '"request": "$request", '
65+
# '"request_method": "$request_method", '
66+
# '"host": "$host",'
67+
# '"upstream_addr": "$upstream_addr",'
68+
# '"http_x_forwarded_for": "$http_x_forwarded_for",'
69+
# '"http_referrer": "$http_referer", '
70+
# '"http_user_agent": "$http_user_agent", '
71+
# '"http_version": "$server_protocol", '
72+
# '"nginx_access": true }';
73+
# access_log /dev/stdout nginxlog_json;
74+
75+
# See Move default writable paths to a dedicated directory (#119)
76+
# https://github.com/openresty/docker-openresty/issues/119
77+
client_body_temp_path /var/run/openresty/nginx-client-body;
78+
proxy_temp_path /var/run/openresty/nginx-proxy;
79+
fastcgi_temp_path /var/run/openresty/nginx-fastcgi;
80+
uwsgi_temp_path /var/run/openresty/nginx-uwsgi;
81+
scgi_temp_path /var/run/openresty/nginx-scgi;
82+
83+
sendfile on;
84+
#tcp_nopush on;
85+
86+
client_max_body_size 128m;
87+
88+
#keepalive_timeout 0;
89+
keepalive_timeout 60;
90+
91+
send_timeout 80s;
92+
client_header_timeout 60s;
93+
client_body_timeout 60s;
94+
resolver_timeout 30s;
95+
proxy_connect_timeout 60s;
96+
proxy_read_timeout 80s;
97+
proxy_send_timeout 80s;
98+
99+
100+
proxy_request_buffering off;
101+
102+
#gzip on;
103+
104+
include /etc/nginx/conf.d/default.conf;
105+
106+
# Don't reveal OpenResty version to clients.
107+
# server_tokens off;
108+
}
109+

0 commit comments

Comments
 (0)