Compare commits

..

12 Commits

Author SHA1 Message Date
Oscar Krause
39b73bb6ca Merge branch 'python-josepy' into 'main'
Migrate from "python-jose" to an alternative

See merge request oscar.krause/fastapi-dls!52
2025-05-21 07:48:42 +02:00
Oscar Krause
2065a33571 fixed debian dependencies 2025-05-21 07:48:40 +02:00
Oscar Krause
608ec9fb6c fixed pacman dependencies 2025-05-21 07:48:40 +02:00
Oscar Krause
c0d23e78cd finished migration 2025-05-21 07:48:40 +02:00
Oscar Krause
fd89cd0785 fixes 2025-05-21 07:48:40 +02:00
Oscar Krause
f58e54cf28 moved from josepy to pyjwt 2025-05-21 07:48:40 +02:00
Oscar Krause
26a5bdb320 fixed pacman dependency 2025-05-21 07:48:40 +02:00
Oscar Krause
6b2c8d512a migrate from "python-jose" to "python3-josepy" since it is no longer supported on future releases of debian/ubuntu 2025-05-21 07:48:40 +02:00
Oscar Krause
bffa357225 typos 2025-05-21 07:19:50 +02:00
Oscar Krause
656d568cbe removed gitea links 2025-05-21 06:35:53 +02:00
Oscar Krause
82c8e89d8f fixes 2025-05-19 12:05:23 +02:00
Oscar Krause
2ee92b6f81 added "Nginx Reverse Proxy (experimental)" section 2025-05-19 12:05:00 +02:00

137
README.md
View File

@ -18,7 +18,6 @@ Only the clients need a connection to this service on configured port.
**Official Links**
* https://git.collinwebdesigns.de/oscar.krause/fastapi-dls (Private Git)
* https://gitea.publichub.eu/oscar.krause/fastapi-dls (Public Git)
* https://hub.docker.com/r/collinwebdesigns/fastapi-dls (Docker-Hub `collinwebdesigns/fastapi-dls:latest`)
*All other repositories are forks! (which is no bad - just for information and bug reports)*
@ -413,7 +412,141 @@ acme.sh --issue -d example.com \
After first success you have to replace `--issue` with `--renew`.
# Configuration
## Nginx Reverse Proxy (experimental)
- This guide is written for Debian/Ubuntu systems, other may work, but you have to do your setup on your own
- Uvicorn does no longer serve requests directly
- NGINX is used as HTTP & HTTPS entrypoint
- Assumes you already have set up webserver certificate and private-key
**Install Nginx Webserver**
```shell
apt-get install nginx-light
```
**Remove default vhost**
```shell
rm /etc/nginx/sites-enabled/default
```
**Create fastapi-dls vhost**
<details>
<summary>`/etc/nginx/sites-available/fastapi-dls`</summary>
```
upstream dls-backend {
server 127.0.0.1:8000; # must match dls listen port
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
root /var/www/html;
index index.html;
server_name _;
ssl_certificate "/etc/fastapi-dls/cert/webserver.crt";
ssl_certificate_key "/etc/fastapi-dls/cert/webserver.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_protocols TLSv1.3 TLSv1.2;
# ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305";
# ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;
location / {
# https://www.uvicorn.org/deployment/
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://dls-backend$request_uri;
}
location = /-/health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{\"status\":\"up\",\"service\":\"nginx\"}';
}
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html;
server_name _;
location /leasing/v1/lessor/shutdown {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://dls-backend/leasing/v1/lessor/shutdown;
}
location / {
return 301 https://$host$request_uri;
}
}
```
</details>
**Enable and test vhost**
```shell
ln -s /etc/nginx/sites-available/fastapi-dls /etc/nginx/sites-enabled/fastapi-dls
nginx -t
# nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
# nginx: configuration file /etc/nginx/nginx.conf test is successful
```
**Override default fastapi-dls systemd service**
```shell
mkdir /etc/systemd/system/fastapi-dls.service.d
```
<details>
<summary>`/etc/systemd/system/fastapi-dls.service.d/override.conf`</summary>
```
[Service]
ExecStart=
ExecStart=uvicorn main:app \
--env-file /etc/fastapi-dls/env \
--host 127.0.0.1 --port 8000 \
--app-dir /usr/share/fastapi-dls/app \
--proxy-headers
```
</details>
**Run**
```shell
systemctl daemon-reload
service nginx start
service fastapi-dls start
```
# Configuration (Service)
| Variable | Default | Usage |
|------------------------|----------------------------------------|------------------------------------------------------------------------------------------------------|