1 { env, yourls, yourls-plugins, config }:
6 install -m 0755 -o ${apache.user} -g ${apache.group} -d /var/lib/php/sessions/yourls
9 keys."webapps/tools-yourls" = {
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();
30 define( 'LDAPAUTH_HOST', 'ldaps://${env.ldap.host}' );
31 define( 'LDAPAUTH_PORT', '636' );
32 define( 'LDAPAUTH_BASE', '${env.ldap.base}' );
33 define( 'LDAPAUTH_SEARCH_USER', '${env.ldap.dn}' );
34 define( 'LDAPAUTH_SEARCH_PASS', '${env.ldap.password}' );
36 define( 'LDAPAUTH_GROUP_ATTR', 'memberof' );
37 define( 'LDAPAUTH_GROUP_REQ', 'cn=admin,cn=yourls,ou=services,dc=immae,dc=eu');
39 define( 'LDAPAUTH_USERCACHE_TYPE', 0);
43 file.datetime = "2022-08-27T18:00:00";
46 description = "Your own URL shortener";
47 website = "https://tools.immae.eu/url/admin/";
48 logo = "https://tools.immae.eu/url/images/favicon.gif";
50 status.description = "OK";
51 registration."" = ["MEMBER" "CLIENT"];
52 registration.load = "FULL";
53 install.type = "PACKAGE";
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;
65 webRoot = (yourls.override { yourls_config = config.secrets.fullPaths."webapps/tools-yourls"; }).withPlugins (p: [p.ldap]);
69 modules = [ "proxy_fcgi" ];
71 vhostConf = socket: ''
75 SetHandler "proxy:unix:${socket}|fcgi://localhost"
80 <IfModule mod_rewrite.c>
83 RewriteCond %{REQUEST_FILENAME} !-f
84 RewriteCond %{REQUEST_FILENAME} !-d
85 RewriteRule ^.*$ /url/yourls-loader.php [L]
87 DirectoryIndex index.php
92 serviceDeps = [ "mysql.service" "openldap.service" ];
93 basedir = builtins.concatStringsSep ":" (
94 [ webRoot config.secrets.fullPaths."webapps/tools-yourls" ]
97 "listen.owner" = apache.user;
98 "listen.group" = apache.group;
100 "pm.max_children" = "60";
101 "pm.process_idle_timeout" = "60";
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";