Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPS v2 #76

Merged
merged 2 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
test/
spec/
examples/
api/node_modules
api/dist
api/.env
api/.git
Dockerfile
build
build_*
node_modules
2 changes: 1 addition & 1 deletion api/.eslintrc → .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
// ### This project uses docker-compose which has many variables not in camelCase
"@typescript-eslint/camelcase": "off"
}
}
}
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ on:

jobs:
unit-test:
defaults:
run:
working-directory: api
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "10.x"
node-version: "19.x"
- run: yarn
- run: yarn build
- run: yarn lint
Expand Down
14 changes: 3 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
test/
spec/examples.txt
Research
/build_*

# API
node_modules/
dist/
.env
.DS_Store
/api/domains_dir/
build
build_*
node_modules
3 changes: 0 additions & 3 deletions .rspec

This file was deleted.

1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

75 changes: 17 additions & 58 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,70 +1,29 @@
FROM ruby:3.1.2-alpine AS ruby-builder
FROM node:19.1 as builder

RUN apk add --update build-base
WORKDIR /usr/src/app

COPY ./Gemfile .
RUN bundle install
COPY *.json yarn.lock ./

FROM node:12-alpine AS node-builder
RUN yarn

WORKDIR /src/api/
COPY ./src ./src
RUN yarn build

# Install all deps to build
COPY api/package.json api/yarn.lock ./
RUN yarn install
FROM node:19.1-alpine
RUN apk add nginx openssl

COPY ./api ./
RUN yarn run build

# Re-install only production for final layer
RUN rm -rf node_modules && yarn install --production

FROM nginx:1.22.0-alpine AS final-stage
ARG TARGETPLATFORM

# Delete sym links from nginx image, install logrotate
RUN rm /var/log/nginx/access.log && \
rm /var/log/nginx/error.log

WORKDIR /root

ENV S6_OVERLAY_VERSION=v2.2.0.1 \
ACME_TINY_VERSION=4.1.0 \
# API volume to store domain .txt and .json files
DOMAINS_DIR=/var/run/domains.d/ \
FULLDOMAIN_PATH=/var/run/domains.d/fulldomain \
ENV DOMAINS_DIR=/usr/src/app/domains \
DAPPMANAGER_SIGN=http://my.dappnode/sign \
DAPPMANAGER_DOMAIN=http://my.dappnode/global-envs/DOMAIN \
DYNAMIC_UPSTREAM=true \
RESOLVER=127.0.0.11 \
GLOBAL_RESOLVER=172.33.1.2 \
DAPPMANAGER_INTERNAL_IP=http://my.dappnode/global-envs/INTERNAL_IP

ADD https://github.com/just-containers/s6-overlay/releases/download/$S6_OVERLAY_VERSION/s6-overlay-amd64.tar.gz /tmp/
ADD https://github.com/just-containers/s6-overlay/releases/download/$S6_OVERLAY_VERSION/s6-overlay-aarch64.tar.gz /tmp/
ADD https://raw.githubusercontent.com/diafygi/acme-tiny/$ACME_TINY_VERSION/acme_tiny.py /bin/acme_tiny

RUN export ARCH=$(echo $TARGETPLATFORM | cut -d'/' -f2 | sed 's/arm64/aarch64/') && \
tar xzf /tmp/s6-overlay-$ARCH.tar.gz -C / && \
rm /tmp/s6-overlay-*.tar.gz && \
rm /etc/nginx/conf.d/default.conf && \
apk add --update \
# From original image
python3 ruby=3.1.2-r0 iproute2 apache2-utils logrotate openssl \
# For Typescript app
nodejs \
&& \
mkdir -p /src/api

ENV GEM_PATH="${GEM_PATH}${GEM_PATH:+:}/usr/local/bundle/"
LOCAL_PROXY_DOMAIN=dappnode

COPY --from=ruby-builder /usr/local/bundle/ /usr/local/bundle/
COPY ./fs_overlay /
COPY --from=node-builder /src/api/node_modules /src/api/node_modules
COPY --from=node-builder /src/api/dist /src/api/
RUN chmod a+x /bin/*
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
COPY ./templates ./templates
RUN yarn --production

VOLUME /var/lib/https-portal
VOLUME /var/log/nginx
COPY --from=builder /usr/src/app/build/ ./build/

ENTRYPOINT ["/init"]
EXPOSE 8545
CMD [ "node", "build/index" ]
6 changes: 0 additions & 6 deletions Gemfile

This file was deleted.

46 changes: 0 additions & 46 deletions Gemfile.lock

This file was deleted.

22 changes: 0 additions & 22 deletions LICENSE

This file was deleted.

19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# HTTPS

This is a fork of an original [https-portal](https://github.com/SteveLTN/https-portal), with additional features intended to be used in [DAppNode](https://github.com/dappnode/DAppNode) as one of the core packages. All of its existing features should remain functional.
# HTTPS-v2

This package serves as proxy server to DAppNodes packages.
<p align="center"><a href="#"><img width="150" title="HTTPS" src='https-portal-avatar.png' /></a></p>

## Configurable forwarding

API was added through which containers proxied through portal can be dynamically chosen. By default the server listens at port `5000` for `GET` methods `add` and `remove` both of which have `to` and `from` query parameters i.e.
API was added through which containers proxied through the package can be dynamically chosen. By default the server listens at port `5000` for `GET` methods `add` and `remove` both of which have `to` and `from` query parameters i.e.

```
GET /add?from=<chosen-subodomain>&to=<internal-resource>
Expand All @@ -17,17 +16,7 @@ Where `chosen-subdomain` is the chosen external endpoint for forwarding and `int

## DAppNode certificates

When using the DAppNode dyndns service, https-portal uses DAppNode's certificate service to get wildcard certificates for the DAppNode dyndns domains which are provided for free. In this mode, the following environment variables have to be set:
When using the DAppNode dyndns service, DNP_HTTPS uses DAppNode's certificate service to get wildcard certificates for the DAppNode dyndns domains which are provided for free. Following environment variable has to be set:
| Name | Value | Description |
| -------------- | --------------------- | ----------------------------- |
| CERTAPI_URL | TBD | URL of remote signing service |

This mode can only be used within DAppNode as a package.

## Running DAppNode on your own domain

It is even possible to run DAppNode on your own domain. Your domain and all of its subdomains should resolve to the pubilc IP of the DAppNode. But please note, for every subdomain a certificate is requested, since it uses HTTP challenges which cannot be used for issuing wildcard certificates.
In this mode, the following environment variables have to be set:
| Name | Value | Description |
| -------------- | --------------------- | ------------------ |
| PUBLIC_DOMAIN | | Your domain |
5 changes: 0 additions & 5 deletions Readme.armhf

This file was deleted.

5 changes: 0 additions & 5 deletions api/.dockerignore

This file was deleted.

13 changes: 0 additions & 13 deletions api/.prettierrc

This file was deleted.

13 changes: 0 additions & 13 deletions api/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions api/package.json

This file was deleted.

13 changes: 0 additions & 13 deletions api/src/config.ts

This file was deleted.

8 changes: 0 additions & 8 deletions api/src/db.ts

This file was deleted.

7 changes: 0 additions & 7 deletions api/src/index.ts

This file was deleted.

15 changes: 0 additions & 15 deletions api/src/nginx.ts

This file was deleted.

14 changes: 0 additions & 14 deletions api/src/utils/domainsFile.ts

This file was deleted.

Loading