]>
Commit | Line | Data |
---|---|---|
da30ae4f | 1 | { env, yourls, yourls-plugins, config }: |
b44b42a1 | 2 | rec { |
4288c2f2 IB |
3 | activationScript = { |
4 | deps = [ "httpd" ]; | |
5 | text = '' | |
6 | install -m 0755 -o ${apache.user} -g ${apache.group} -d /var/lib/php/sessions/yourls | |
7 | ''; | |
8 | }; | |
4c4652aa | 9 | keys."webapps/tools-yourls" = { |
b44b42a1 IB |
10 | user = apache.user; |
11 | group = apache.group; | |
12 | permissions = "0400"; | |
13 | text = '' | |
14 | <?php | |
15 | define( 'YOURLS_DB_USER', '${env.mysql.user}' ); | |
16 | define( 'YOURLS_DB_PASS', '${env.mysql.password}' ); | |
17 | define( 'YOURLS_DB_NAME', '${env.mysql.database}' ); | |
18 | define( 'YOURLS_DB_HOST', '${env.mysql.host}' ); | |
19 | define( 'YOURLS_DB_PREFIX', 'yourls_' ); | |
20 | define( 'YOURLS_SITE', 'https://tools.immae.eu/url' ); | |
21 | define( 'YOURLS_HOURS_OFFSET', 0 ); | |
22 | define( 'YOURLS_LANG', ''' ); | |
23 | define( 'YOURLS_UNIQUE_URLS', true ); | |
24 | define( 'YOURLS_PRIVATE', true ); | |
25 | define( 'YOURLS_COOKIEKEY', '${env.cookieKey}' ); | |
26 | $yourls_user_passwords = array(); | |
27 | define( 'YOURLS_DEBUG', false ); | |
28 | define( 'YOURLS_URL_CONVERT', 36 ); | |
29 | $yourls_reserved_URL = array(); | |
ab8f306d | 30 | define( 'LDAPAUTH_HOST', 'ldaps://${env.ldap.host}' ); |
b44b42a1 | 31 | define( 'LDAPAUTH_PORT', '636' ); |
ab8f306d IB |
32 | define( 'LDAPAUTH_BASE', '${env.ldap.base}' ); |
33 | define( 'LDAPAUTH_SEARCH_USER', '${env.ldap.dn}' ); | |
b44b42a1 | 34 | define( 'LDAPAUTH_SEARCH_PASS', '${env.ldap.password}' ); |
133ebaee | 35 | |
b44b42a1 IB |
36 | define( 'LDAPAUTH_GROUP_ATTR', 'memberof' ); |
37 | define( 'LDAPAUTH_GROUP_REQ', 'cn=admin,cn=yourls,ou=services,dc=immae,dc=eu'); | |
133ebaee | 38 | |
b44b42a1 IB |
39 | define( 'LDAPAUTH_USERCACHE_TYPE', 0); |
40 | ''; | |
4c4652aa | 41 | }; |
120bcf4d IB |
42 | chatonsProperties = { |
43 | file.datetime = "2022-08-27T18:00:00"; | |
44 | service = { | |
45 | name = "Yourls"; | |
46 | description = "Your own URL shortener"; | |
47 | website = "https://tools.immae.eu/url/admin/"; | |
48 | logo = "https://tools.immae.eu/url/images/favicon.gif"; | |
49 | status.level = "OK"; | |
50 | status.description = "OK"; | |
51 | registration."" = ["MEMBER" "CLIENT"]; | |
52 | registration.load = "FULL"; | |
53 | install.type = "PACKAGE"; | |
54 | }; | |
55 | software = { | |
56 | name = "YOURLS"; | |
57 | website = "http://yourls.org/"; | |
58 | license.url = "https://github.com/YOURLS/YOURLS/blob/master/LICENSE"; | |
59 | license.name = "MIT License"; | |
60 | version = webRoot.version; | |
61 | source.url = "https://github.com/YOURLS/YOURLS"; | |
62 | modules = map (a: a.pluginName) webRoot.plugins; | |
63 | }; | |
64 | }; | |
da30ae4f | 65 | webRoot = (yourls.override { yourls_config = config.secrets.fullPaths."webapps/tools-yourls"; }).withPlugins (p: [p.ldap]); |
b44b42a1 IB |
66 | apache = rec { |
67 | user = "wwwrun"; | |
68 | group = "wwwrun"; | |
69 | modules = [ "proxy_fcgi" ]; | |
750fe5a4 | 70 | root = webRoot; |
5400b9b6 | 71 | vhostConf = socket: '' |
b44b42a1 IB |
72 | Alias /url "${root}" |
73 | <Directory "${root}"> | |
74 | <FilesMatch "\.php$"> | |
5400b9b6 | 75 | SetHandler "proxy:unix:${socket}|fcgi://localhost" |
b44b42a1 | 76 | </FilesMatch> |
133ebaee | 77 | |
b44b42a1 IB |
78 | AllowOverride None |
79 | Require all granted | |
80 | <IfModule mod_rewrite.c> | |
81 | RewriteEngine On | |
82 | RewriteBase /url/ | |
83 | RewriteCond %{REQUEST_FILENAME} !-f | |
84 | RewriteCond %{REQUEST_FILENAME} !-d | |
85 | RewriteRule ^.*$ /url/yourls-loader.php [L] | |
86 | </IfModule> | |
87 | DirectoryIndex index.php | |
88 | </Directory> | |
89 | ''; | |
90 | }; | |
91 | phpFpm = rec { | |
92 | serviceDeps = [ "mysql.service" "openldap.service" ]; | |
93 | basedir = builtins.concatStringsSep ":" ( | |
da30ae4f | 94 | [ webRoot config.secrets.fullPaths."webapps/tools-yourls" ] |
b44b42a1 | 95 | ++ webRoot.plugins); |
5400b9b6 IB |
96 | pool = { |
97 | "listen.owner" = apache.user; | |
98 | "listen.group" = apache.group; | |
99 | "pm" = "ondemand"; | |
100 | "pm.max_children" = "60"; | |
101 | "pm.process_idle_timeout" = "60"; | |
133ebaee | 102 | |
5400b9b6 IB |
103 | # Needed to avoid clashes in browser cookies (same domain) |
104 | "php_value[session.name]" = "YourlsPHPSESSID"; | |
105 | "php_admin_value[open_basedir]" = "${basedir}:/tmp:/var/lib/php/sessions/yourls"; | |
106 | "php_admin_value[session.save_path]" = "/var/lib/php/sessions/yourls"; | |
107 | }; | |
133ebaee | 108 | }; |
b44b42a1 | 109 | } |