fix: Files moved, docs updated and server updated:

* Moved files around for better consistency
* Simplified docker file for use
* Added a  arg to the server/setup.py script for more flexibility
* Improved the current docker build and compose for the fully patched pritunl.
This commit is contained in:
Amir Moradi
2023-05-23 11:13:50 +01:00
parent c01a7d9c98
commit de5076c218
12 changed files with 329 additions and 98 deletions

View File

@@ -1,6 +1,9 @@
FROM goofball222/pritunl:latest
ARG API_SERVER_DOMAIN
ENV API_SERVER_DOMAIN $API_SERVER_DOMAIN
# Yes, you will need to copy it over into the build context...
COPY setup.py .
RUN chmod +x setup.py; python3 -u setup.py --install; rm setup.py
RUN chmod +x setup.py; python3 -u setup.py --install --api-server ${API_SERVER_DOMAIN:-}; rm setup.py

View File

@@ -0,0 +1,40 @@
# Pritunl Fake API Server definition
server {
listen [::]:80 default_server;
listen 80 default_server;
server_name _;
sendfile off;
tcp_nodelay on;
absolute_redirect off;
root /var/www/html;
index index.php index.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.php
try_files $uri $uri/ /index.php?path=$uri&$args;
}
# Pass the PHP scripts to PHP-FPM listening on php-fpm.sock
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}
# Deny access to . files, for security
location ~ /\. {
log_not_found off;
deny all;
}
}

View File

@@ -0,0 +1,98 @@
# Runs this API, either on port 80 or behind Traefik, either on docker swarm or single daemon.
# Choose the right configuration for you and comment out the other.
# Read the comments carefully.
#
#
# In case you run behind Traefik, you need to setup the traefik router HOST
# You need correctly setup traefik and docker network (here called proxy_external)
#
# /!\ /!\ Make sure the mount volumes match correctly. /!\ /!\
#
# The first volume is the path to the www folder from the root of this repo.
# The path shall be a full path, or be next to this docker-compose.yml file.
# No parent folder navigation like `../../../` is allowed by docker.
#
# -> Easy solution:
# Once you have cloned this repo, you shall move this docker-compose.yml file to the root of the repo.
#
# The second volume is the path to the nginx server config file.
# This needs the commited nginx server config (or your own adapted version) to work properly.
# See the file `<repo_root>/docker/api-only/conf.d/pritunl-fake-api.conf` for more details.
version: '3.7'
services:
web:
image: trafex/php-nginx
volumes:
- "./www:/var/www/html:ro"
- "./docker/api-only/conf.d/pritunl-fake-api.conf:/etc/nginx/conf.d/pritunl-fake-api.conf"
#################################################################
### If you run behind Traefik COMMENT OUT the following lines ###
### BEGIN TRAEFIK_BLOCK ###
ports:
- "80:8080"
#################################################################
#################################################################
### BEGIN SINGLE_DAEMON_BLOCK ###
### If you run behind on Docker Single Daemon (NOT Swarm) uncomment the following lines ###
# networks:
# - default
# - proxy_external
# labels:
# - "traefik.enable=true"
# - "traefik.docker.network=proxy_external"
# - "traefik.tags=proxy_external"
# ### Services
# ## API
# - "traefik.http.services.pritunl-api.loadbalancer.server.port=8080"
# ### Routers
# - "traefik.http.routers.pritunl-api.entrypoints=https"
# - "traefik.http.routers.pritunl-api.rule=Host(`mypritunlfakeapi.example.com`)"
# - "traefik.http.routers.pritunl-api.service=pritunl-api"
# - "traefik.http.routers.pritunl-api.tls=true"
# - "traefik.http.routers.pritunl-api.tls.certresolver=http"
# networks:
# proxy_external:
# external: true
# name: proxy_external
### END SINGLE_DAEMON_BLOCK ###
### BEGIN SWARM_BLOCK ###
### If you run on Docker Swarm uncomment the following lines ###
# networks:
# - default
# - proxy_external
# labels:
# - "traefik.enable=true"
# deploy:
# labels:
# - "traefik.enable=true"
# - "traefik.docker.network=proxy_external"
# - "traefik.tags=proxy_external"
# ### Services
# ## API
# - "traefik.http.services.pritunl-api.loadbalancer.server.port=8080"
# ### Routers
# - "traefik.http.routers.pritunl-api.entrypoints=https"
# - "traefik.http.routers.pritunl-api.rule=Host(`mypritunlfakeapi.example.com`)"
# - "traefik.http.routers.pritunl-api.service=pritunl-api"
# - "traefik.http.routers.pritunl-api.tls=true"
# - "traefik.http.routers.pritunl-api.tls.certresolver=http"
# networks:
# proxy_external:
# external: true
# name: proxy_external
### END SWARM_BLOCK ###
### END TRAEFIK BLOCK ###
#################################################################

View File

@@ -11,6 +11,8 @@ services:
build:
context: ../server
dockerfile: ../docker/Dockerfile
args:
- API_SERVER_DOMAIN=${API_SERVER_DOMAIN:-}
restart: always
depends_on:
- mongodb