Skip to content

Commit fe3904c

Browse files
committed
Merge branch 'main' into ft-ldap
2 parents ea03702 + 77a616d commit fe3904c

File tree

7 files changed

+203
-7
lines changed

7 files changed

+203
-7
lines changed

README.md

+27-7
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,36 @@ This project is a Dockerized application, and Docker Compose is used for the orc
2323
127.0.0.1 app.pygeoapi.local
2424
```
2525

26-
This step is necessary to resolve the local domains used in the Caddyfile.
26+
This step is necessary to resolve the local domains used in the Caddyfile or Nginx.
2727

28-
1. **Start the Services:**
29-
From the root directory of the project, start all the services using Docker Compose with the following command:
28+
2. **Start the Services :**
3029

31-
```bash
32-
docker-compose up -d
33-
```
30+
- ### Using Caddy
31+
32+
1. **Run the Services with Docker**:
33+
From the root directory of the project, start all the services using Docker Compose with the following command:
34+
35+
```bash
36+
docker-compose up -d
37+
```
38+
39+
- ### Using Nginx
40+
41+
1. **Generate Self-Signed Certificates**:
42+
43+
> [!IMPORTANT]
44+
> You must generate self-signed certificates for the local domains before starting the services.
45+
46+
Follow the provided instructions in [README.md](nginx/README.md) to generate self-signed certificates for the local domains or use your own certificates.
47+
48+
2. **Run the Services with Docker**:
49+
From the root directory of the project, start all the services using Docker Compose with the following command:
50+
51+
```bash
52+
docker compose -f "docker-compose-nginx.yml" up -d
53+
```
3454

35-
This command pulls the necessary Docker images and starts the services defined in docker-compose.yml.
55+
This command pulls the necessary Docker images and starts the services defined in docker-compose.yml (for Caddy) or docker-compose-nginx.yml (for Nginx).
3656

3757
## Testing Scenarios
3858

authelia/configuration.yml

+12
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ session:
8787
inactivity: 5m
8888
expiration: 1h
8989
remember_me: 5M
90+
<<<<<<< HEAD
9091
# Remove the `cookies` block if keeping `domain`, or vice versa
9192
domain: "pygeoapi.local"
9293
# cookies:
@@ -98,6 +99,17 @@ session:
9899
# inactivity: "5m"
99100
# expiration: "1h"
100101
# remember_me: "1d"
102+
=======
103+
cookies:
104+
- domain: "pygeoapi.local"
105+
authelia_url: "https://pygeoapi.local"
106+
default_redirection_url: "https://app.pygeoapi.local/api"
107+
name: "authelia_session"
108+
same_site: "lax"
109+
inactivity: "5m"
110+
expiration: "1h"
111+
remember_me: "1d"
112+
>>>>>>> main
101113

102114
redis:
103115
host: redis

docker-compose-nginx.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
services:
3+
nginx:
4+
container_name: nginx
5+
image: lscr.io/linuxserver/nginx
6+
restart: unless-stopped
7+
networks:
8+
- nginx
9+
ports:
10+
- 80:80
11+
- 443:443
12+
volumes:
13+
- ./nginx/site-confs:/config/nginx/site-confs
14+
- ./nginx/snippets:/config/nginx/snippets
15+
- ./nginx/certs:/config/ssl # see nginx/README.md to generate self signed certs in this directory
16+
environment:
17+
TZ: 'UTC'
18+
DOCKER_MODS: 'linuxserver/mods:nginx-proxy-confs'
19+
20+
authelia:
21+
container_name: authelia
22+
image: authelia/authelia:4.38.9
23+
restart: unless-stopped
24+
networks:
25+
- nginx
26+
ports:
27+
- 9091:9091
28+
volumes:
29+
- ./authelia:/config
30+
depends_on:
31+
- redis
32+
33+
redis:
34+
container_name: redis
35+
image: redis:7.0
36+
restart: unless-stopped
37+
networks:
38+
- nginx
39+
40+
pygeoapi:
41+
container_name: pygeoapi
42+
image: geopython/pygeoapi:latest
43+
volumes:
44+
- ./pygeoapi-config.yml:/pygeoapi/local.config.yml
45+
environment:
46+
- SCRIPT_NAME=/api
47+
depends_on:
48+
- redis
49+
- nginx
50+
- authelia
51+
networks:
52+
- nginx
53+
54+
networks:
55+
nginx:
56+
name: nginx

nginx/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Generate SSL certificates for the Nginx
2+
3+
```bash
4+
cd ./nginx/certs
5+
```
6+
7+
### Generate a private key
8+
9+
```bash
10+
openssl genpkey -algorithm RSA -out pygeoapi.key
11+
```
12+
13+
### Generate a certificate signing request (CSR)
14+
15+
```bash
16+
openssl req -new -key pygeoapi.key -out pygeoapi.csr -subj "/C=EG/ST=Cairo/L=Cairo/O=Pygeoapi/OU=IT Department/CN=\*.pygeoapi.local"
17+
```
18+
19+
### Generate the self-signed certificate
20+
21+
```bash
22+
openssl x509 -req -days 365 -in pygeoapi.csr -signkey pygeoapi.key -out pygeoapi.crt
23+
```

nginx/certs/.gitkeep

Whitespace-only changes.

nginx/site-confs/default.conf

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
server {
2+
listen 80;
3+
server_name pygeoapi.local app.pygeoapi.local;
4+
return 301 https://$host$request_uri;
5+
}
6+
7+
server {
8+
listen 443 ssl;
9+
server_name pygeoapi.local;
10+
11+
ssl_certificate /config/ssl/pygeoapi.crt;
12+
ssl_certificate_key /config/ssl/pygeoapi.key;
13+
14+
location / {
15+
proxy_pass http://authelia:9091;
16+
proxy_set_header Host $host;
17+
proxy_set_header X-Real-IP $remote_addr;
18+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19+
proxy_set_header X-Forwarded-Proto $scheme;
20+
}
21+
}
22+
23+
server {
24+
listen 443 ssl;
25+
server_name app.pygeoapi.local;
26+
27+
ssl_certificate /config/ssl/pygeoapi.crt;
28+
ssl_certificate_key /config/ssl/pygeoapi.key;
29+
30+
location /authelia {
31+
internal;
32+
proxy_pass http://authelia:9091/api/verify;
33+
proxy_set_header Content-Length "";
34+
proxy_pass_request_body off;
35+
proxy_set_header Host $host;
36+
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
37+
proxy_set_header X-Real-IP $remote_addr;
38+
proxy_set_header X-Forwarded-For $remote_addr;
39+
proxy_set_header X-Forwarded-Proto $scheme;
40+
proxy_set_header X-Forwarded-Host $http_host;
41+
proxy_set_header X-Forwarded-Uri $request_uri;
42+
proxy_set_header X-Forwarded-Ssl on;
43+
proxy_set_header Proxy-Authorization $http_authorization;
44+
proxy_redirect http:// $scheme://;
45+
proxy_http_version 1.1;
46+
proxy_set_header Connection "";
47+
proxy_cache_bypass $cookie_session;
48+
proxy_no_cache $cookie_session;
49+
proxy_buffers 4 32k;
50+
client_body_buffer_size 128k;
51+
send_timeout 5m;
52+
proxy_read_timeout 240;
53+
proxy_send_timeout 240;
54+
proxy_connect_timeout 240;
55+
}
56+
57+
location / {
58+
auth_request /authelia;
59+
auth_request_set $target_url $scheme://$http_host$request_uri;
60+
auth_request_set $user $upstream_http_remote_user;
61+
auth_request_set $groups $upstream_http_remote_groups;
62+
proxy_set_header Remote-User $user;
63+
proxy_set_header Remote-Groups $groups;
64+
error_page 401 =302 https://pygeoapi.local/?rd=$target_url;
65+
66+
proxy_pass http://pygeoapi:80;
67+
proxy_set_header Host $host;
68+
proxy_set_header X-Real-IP $remote_addr;
69+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
70+
proxy_set_header X-Forwarded-Proto $scheme;
71+
proxy_set_header X-Forwarded-Host $http_host;
72+
proxy_set_header X-Forwarded-Uri $request_uri;
73+
proxy_set_header X-Forwarded-Ssl on;
74+
proxy_redirect http:// $scheme://;
75+
proxy_http_version 1.1;
76+
proxy_set_header Connection "";
77+
proxy_cache_bypass $cookie_session;
78+
proxy_no_cache $cookie_session;
79+
proxy_buffers 64 256k;
80+
send_timeout 5m;
81+
proxy_read_timeout 360;
82+
proxy_send_timeout 360;
83+
proxy_connect_timeout 360;
84+
}
85+
}

nginx/snippets/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)