Skip to content

Commit

Permalink
add RELAY variable
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Aug 14, 2024
1 parent 426b88a commit 85d94c0
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes

* 2024-08-14: add RELAY variable
* 2024-08-13: add reCaptcha plugin
* 2024-07-24: update to 2.19.1
* 2024-07-15: add sessions-backup task docker (v2.19.0-9)
Expand Down
2 changes: 2 additions & 0 deletions portal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ yadd/lemonldap-ng-cron-task)_.
* `NPROC`: the minimal number of FastCGI server to start _(default: 7)_
* `ENGINE`: the FastCGI server engine. _(default: [FCGI](https://metacpan.org/pod/FCGI))_.
You can try [FCGI::Engine::ProcManager](https://metacpan.org/pod/FCGI::Engine::ProcManager).
See also [High performance portal](../uwsgi-portal/README.md).
* `RELAY`: list of reverse-proxies to set. syntax: `<servername>=https://<proxy-dest>/;<servername>=https://<proxy-dest>/...`

See also [yadd/lemonldap-ng-base](https://github.com/guimard/llng-docker/blob/master/base/README.md#readme)

Expand Down
12 changes: 12 additions & 0 deletions portal/__test__/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ version: "3.4"

services:
auth.example.com:
container_name: test_portal_with_supertest
image: yadd/lemonldap-ng-portal
environment:
- LOGGER=stderr
- USERLOGGER=stderr
- "RELAY=foo.example.com=http://auth.example.com/static/"
networks:
portaltest:
aliases:
- foo.example.com
test:
image: yadd/lemonldap-ng-portal-test
build:
context: .
depends_on:
auth.example.com:
condition: service_started
networks:
portaltest:

networks:
portaltest:
name: portaltest
9 changes: 9 additions & 0 deletions portal/__test__/portal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ describe('LLNG portal', () => {
.expect(401,done)
})
})
describe('RELAY', () => {
const request = supertest.agent('http://foo.example.com')
it('should find /languages/fr.json', (done) => {
request.get('/languages/fr.json')
.expect(200)
.then(res => { done() })
.catch(done)
});
})
22 changes: 22 additions & 0 deletions portal/install/etc/cont-init.d/update-nginx-portal-conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,25 @@ s#__DNSDOMAIN__#$ENV{SSODOMAIN}#g;
s#__PORTALSITEDIR__#/usr/share/lemonldap-ng/portal/htdocs/#g;
s#__PORTALSTATICDIR__#/usr/share/lemonldap-ng/portal/htdocs/static/#g;
' /etc/lemonldap-ng/portal-nginx.conf

if test "$RELAY" != ''; then
set -e
perl -e '
use strict;
my $res;
my @list = split /\s*;\s*/, $ENV{RELAY};
foreach(@list) {
die "Bad relay value $_" unless m#^(.*?)=(https?://.*/)$#;
print <<EOF
server {
listen 80;
listen [::]:80;
server_name $1;
location / {
proxy_pass $2;
}
}
EOF
}
' >/etc/nginx/sites-enabled/zzzz-relay.conf
fi
14 changes: 13 additions & 1 deletion uwsgi-portal/__test__/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ version: "3.4"

services:
auth.example.com:
image: "yadd/lemonldap-ng-portal:latest-hiperf"
container_name: test_portal_with_supertest
image: yadd/lemonldap-ng-portal
environment:
- LOGGER=stderr
- USERLOGGER=stderr
- "RELAY=foo.example.com=http://auth.example.com/static/"
networks:
uportaltest:
aliases:
- foo.example.com
test:
image: yadd/lemonldap-ng-portal-test
build:
context: .
depends_on:
auth.example.com:
condition: service_started
networks:
uportaltest:

networks:
uportaltest:
name: uportaltest
9 changes: 9 additions & 0 deletions uwsgi-portal/__test__/portal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ describe('LLNG portal', () => {
.expect(401,done)
})
})
describe('RELAY', () => {
const request = supertest.agent('http://foo.example.com')
it('should find /languages/fr.json', (done) => {
request.get('/languages/fr.json')
.expect(200)
.then(res => { done() })
.catch(done)
});
})
22 changes: 22 additions & 0 deletions uwsgi-portal/install/etc/cont-init.d/update-nginx-portal-conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,25 @@ s#__DNSDOMAIN__#$ENV{SSODOMAIN}#g;
s#__PORTALSITEDIR__#/usr/share/lemonldap-ng/portal/htdocs/#g;
s#__PORTALSTATICDIR__#/usr/share/lemonldap-ng/portal/htdocs/static/#g;
' /etc/lemonldap-ng/portal-nginx.conf

if test "$RELAY" != ''; then
set -e
perl -e '
use strict;
my $res;
my @list = split /\s*;\s*/, $ENV{RELAY};
foreach(@list) {
die "Bad relay value $_" unless m#^(.*?)=(https?://.*/)$#;
print <<EOF
server {
listen 80;
listen [::]:80;
server_name $1;
location / {
proxy_pass $2;
}
}
EOF
}
' >/etc/nginx/sites-enabled/zzzz-relay.conf
fi

0 comments on commit 85d94c0

Please sign in to comment.