Skip to content

Commit

Permalink
First commit for open source
Browse files Browse the repository at this point in the history
  • Loading branch information
yinjiayi committed Sep 5, 2023
0 parents commit 4af6fb5
Show file tree
Hide file tree
Showing 11 changed files with 506 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: container build and push

on:
push:
branches: [ "*" ]
tags: [ '*.*.*' ]
pull_request:
branches: [ "*" ]

env:
REGISTRY: ghcr.io
EULIX_REGISTRY: ${{ secrets.EULIX_REGISTRY }}
IMAGE_NAME: ${{ github.repository }}

jobs:

build:
runs-on: [self-hosted, linux, x64]
permissions:
contents: read
packages: write
id-token: write

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log into registry ${{ env.EULIX_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.EULIX_REGISTRY }}
username: ${{ secrets.EULIX_REGISTRY_USERNAME }}
password: ${{ secrets.EULIX_REGISTRY_PASSWORD }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v2
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.EULIX_REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.vscode
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log

## Version 1.0.1
发布时间:2021.12.7
- 支持从redis读取 network-server 访问地址并进行路由
- 支持在转发头部添加指定字段



27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2022 Institute of Software Chinese Academy of Sciences (ISCAS)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM openresty/openresty:1.21.4.1-4-bullseye-fat
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf
COPY ./conf/rewrite.lua /etc/nginx/conf.d/rewrite.lua
COPY ./conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
COPY entrypoint.sh /entrypoint.sh

RUN sed -i "s/deb.debian.org/mirrors.aliyun.com/g" /etc/apt/sources.list
RUN apt update && apt install --no-install-recommends -y curl && rm -rf /var/lib/apt/lists/*
RUN chmod +x /entrypoint.sh

ENV DOCKER_DNS=192.168.0.10

ENTRYPOINT ["/entrypoint.sh"]
19 changes: 19 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--AOPlatform-Proxy--
Copyright (c) 2022 Institute of Software, Chinese Academy of Sciences (ISCAS)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

--Third Party Software Notices--
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.

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.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# platform proxy

English | [简体中文](./README_cn.md)

## Build And Run

### Compilation environment preparation

Please install the latest version of Docker.

### Source code download

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.

- Create a local directory , run cmd: `mkdir ./platform-proxy`
- Enter the directory, run cmd: `cd ./platform-proxy`
- Run cmd: `git clone [email protected]:ao-space/platform-proxy.git .`

### Container image building

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.。

### Environment variables

- REDIS_ADDR: redis server addr
- REDIS_PORT: redis server port
- REDIS_PASSWORD: redis access password

### Deploy

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`

## Contribution Guidelines

Contributions to this project are very welcome. Here are some guidelines and suggestions to help you get involved in the project.

[Contribution Guidelines](https://github.com/ao-space/ao.space/blob/dev/docs/en/contribution-guidelines.md)

## Contact us

- Email: <[email protected]>
- [Official Website](https://ao.space)
- [Discussion group](https://slack.ao.space)
43 changes: 43 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# platform proxy

[English](README.md) | 简体中文

## 构建和部署

### 构建环境准备

请安装最新版本的 docker 。

### 源码下载

可以通过整体项目源码下载的方式,或通过以下方式:

- 创建本地目录,执行命令: `mkdir ./platform-proxy`
- 进入本地目录,执行命令: `cd ./platform-proxy`
- 下载源码,执行命令: `git clone [email protected]:ao-space/platform-proxy.git .`

### 镜像构建

执行命令: `docker build -t hub.eulix.xyz/ao-space/platform-proxy:dev .` , tag 参数可以根据实际情况修改。

### 环境变量

- REDIS_ADDR: redis 服务器地址
- REDIS_PORT: redis 服务器端口
- REDIS_PASSWORD: redis 访问密码

### 部署服务

执行命令: `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`

## 贡献指南

我们非常欢迎对本项目进行贡献。以下是一些指导原则和建议,希望能够帮助您参与到项目中来。

[贡献指南](https://github.com/ao-space/ao.space/blob/dev/docs/cn/contribution-guidelines.md)

## 联系我们

- 邮箱:<[email protected]>
- [官方网站](https://ao.space)
- [讨论组](https://slack.ao.space)
54 changes: 54 additions & 0 deletions conf/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# nginx.vh.default.conf -- docker-openresty
#
# This file is installed to:
# `/etc/nginx/conf.d/default.conf`
#
# It tracks the `server` section of the upstream OpenResty's `nginx.conf`.
#
# This config (and any other configs in `etc/nginx/conf.d/`) is loaded by
# default by the `include` directive in `/usr/local/openresty/nginx/conf/nginx.conf`.
#
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
#

lua_package_path "/opt/openresty/lualib/lua-resty-redis/lib/?.lua;;";


server {
listen 80;
server_name localhost;
set_by_lua $redis_addr 'return os.getenv("REDIS_ADDR")';
set_by_lua $redis_port 'return os.getenv("REDIS_PORT")';
set_by_lua $redis_password 'return os.getenv("REDIS_PASSWORD")';

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/openresty/nginx/html;
}

location /healthcheck {
default_type text/plain;
return 200 "access success";
}

# 以 / 开头的转发到 box
location / {
set $target '';
set $clientid '' ;

rewrite_by_lua_file "/etc/nginx/conf.d/rewrite.lua" ;

proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header EID $clientid;
proxy_set_header Network-Server-Addr $target;
proxy_set_header Host $http_host;
proxy_pass http://$target;
}
}
109 changes: 109 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# nginx.conf -- docker-openresty
#
# This file is installed to:
# `/usr/local/openresty/nginx/conf/nginx.conf`
# and is the file loaded by nginx at startup,
# unless the user specifies otherwise.
#
# It tracks the upstream OpenResty's `nginx.conf`, but removes the `server`
# section and adds this directive:
# `include /etc/nginx/conf.d/*.conf;`
#
# The `docker-openresty` file `nginx.vh.default.conf` is copied to
# `/etc/nginx/conf.d/default.conf`. It contains the `server section
# of the upstream `nginx.conf`.
#
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
#

#user nobody;
#worker_processes 1;

# Enables the use of JIT for regular expressions to speed-up their processing.
pcre_jit on;



#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 65535;
}

env REDIS_ADDR;
env REDIS_PORT;
env REDIS_PASSWORD;

http {
include mime.types;
default_type application/octet-stream;
resolver <resolver> valid=30s ipv6=off;
#resolver 192.168.10.1 valid=30s ipv6=off;

# Enables or disables the use of underscores in client request header fields.
# 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.
# underscores_in_headers off;
log_format main '$remote_addr - $remote_user [$time_local] [$http_host] "$request" '
'$status $body_bytes_sent request_time:$request_time response_time:$upstream_response_time "$http_referer" "$http_bp_network_server" "$http_bp_forward_client_id" '
'"$http_user_agent" "$http_x_forwarded_for" request-id:"$http_request_id" cookie_client_uuid:"$cookie_client_uuid" ';

access_log logs/access.log main;
error_log logs/error.log info;

# Log in JSON Format
# log_format nginxlog_json escape=json '{ "timestamp": "$time_iso8601", '
# '"remote_addr": "$remote_addr", '
# '"body_bytes_sent": $body_bytes_sent, '
# '"request_time": $request_time, '
# '"response_status": $status, '
# '"request": "$request", '
# '"request_method": "$request_method", '
# '"host": "$host",'
# '"upstream_addr": "$upstream_addr",'
# '"http_x_forwarded_for": "$http_x_forwarded_for",'
# '"http_referrer": "$http_referer", '
# '"http_user_agent": "$http_user_agent", '
# '"http_version": "$server_protocol", '
# '"nginx_access": true }';
# access_log /dev/stdout nginxlog_json;

# See Move default writable paths to a dedicated directory (#119)
# https://github.com/openresty/docker-openresty/issues/119
client_body_temp_path /var/run/openresty/nginx-client-body;
proxy_temp_path /var/run/openresty/nginx-proxy;
fastcgi_temp_path /var/run/openresty/nginx-fastcgi;
uwsgi_temp_path /var/run/openresty/nginx-uwsgi;
scgi_temp_path /var/run/openresty/nginx-scgi;

sendfile on;
#tcp_nopush on;

client_max_body_size 128m;

#keepalive_timeout 0;
keepalive_timeout 60;

send_timeout 80s;
client_header_timeout 60s;
client_body_timeout 60s;
resolver_timeout 30s;
proxy_connect_timeout 60s;
proxy_read_timeout 80s;
proxy_send_timeout 80s;


proxy_request_buffering off;

#gzip on;

include /etc/nginx/conf.d/default.conf;

# Don't reveal OpenResty version to clients.
# server_tokens off;
}

Loading

0 comments on commit 4af6fb5

Please sign in to comment.