ConfigLMM 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.yardopts +4 -0
- data/CHANGELOG.md +5 -0
- data/Examples/Android.mm.yaml +8 -0
- data/Examples/Apps/Blog.mm.yaml +7 -0
- data/Examples/Apps/Jellyfin.mm.yaml +3 -0
- data/Examples/Implemented.mm.yaml +155 -0
- data/Examples/Keys.ini +7 -0
- data/Examples/Linux.mm.yaml +16 -0
- data/Examples/Windows.mm.yaml +11 -0
- data/Examples/configlmmAuth.sh +26 -0
- data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.conf.erb +38 -0
- data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.lmm.rb +19 -0
- data/Plugins/Apps/IPFS/IPFS.conf.erb +44 -0
- data/Plugins/Apps/IPFS/IPFS.lmm.rb +23 -0
- data/Plugins/Apps/InfluxDB/InfluxDB.conf.erb +34 -0
- data/Plugins/Apps/InfluxDB/InfluxDB.lmm.rb +19 -0
- data/Plugins/Apps/Jackett/Jackett.conf.erb +38 -0
- data/Plugins/Apps/Jackett/Jackett.lmm.rb +19 -0
- data/Plugins/Apps/Jellyfin/Jellyfin.conf.erb +59 -0
- data/Plugins/Apps/Jellyfin/Jellyfin.lmm.rb +23 -0
- data/Plugins/Apps/Mastodon/Mastodon.conf.erb +81 -0
- data/Plugins/Apps/Mastodon/Mastodon.lmm.rb +23 -0
- data/Plugins/Apps/Matrix/Matrix.conf.erb +36 -0
- data/Plugins/Apps/Matrix/Matrix.lmm.rb +23 -0
- data/Plugins/Apps/Netdata/Netdata.conf.erb +37 -0
- data/Plugins/Apps/Netdata/Netdata.lmm.rb +23 -0
- data/Plugins/Apps/Nextcloud/Nextcloud.conf.erb +165 -0
- data/Plugins/Apps/Nextcloud/Nextcloud.lmm.rb +23 -0
- data/Plugins/Apps/Nginx/config-lmm/errors.conf +31 -0
- data/Plugins/Apps/Nginx/config-lmm/private.conf +6 -0
- data/Plugins/Apps/Nginx/config-lmm/proxy.conf +15 -0
- data/Plugins/Apps/Nginx/config-lmm/public.conf +3 -0
- data/Plugins/Apps/Nginx/config-lmm/ssl.conf +18 -0
- data/Plugins/Apps/Nginx/main.conf +30 -0
- data/Plugins/Apps/Nginx/nginx.conf +90 -0
- data/Plugins/Apps/Nginx/nginx.lmm.rb +62 -0
- data/Plugins/Apps/Nginx/proxy.conf.erb +31 -0
- data/Plugins/Apps/Odoo/Odoo.conf.erb +44 -0
- data/Plugins/Apps/Odoo/Odoo.lmm.rb +23 -0
- data/Plugins/Apps/Pterodactyl/Pterodactyl.conf.erb +50 -0
- data/Plugins/Apps/Pterodactyl/Pterodactyl.lmm.rb +30 -0
- data/Plugins/Apps/Pterodactyl/Wings.conf.erb +38 -0
- data/Plugins/Apps/Sunshine/Sunshine.conf.erb +31 -0
- data/Plugins/Apps/Sunshine/Sunshine.lmm.rb +21 -0
- data/Plugins/Apps/Vaultwarden/Vaultwarden.conf.erb +48 -0
- data/Plugins/Apps/Vaultwarden/Vaultwarden.lmm.rb +25 -0
- data/Plugins/Apps/bitmagnet/bitmagnet.conf.erb +35 -0
- data/Plugins/Apps/bitmagnet/bitmagnet.lmm.rb +19 -0
- data/Plugins/Apps/gollum/config.ru +11 -0
- data/Plugins/Apps/gollum/gollum.conf.erb +41 -0
- data/Plugins/Apps/gollum/gollum.lmm.rb +52 -0
- data/Plugins/OS/Linux.lmm.rb +64 -0
- data/Plugins/OS/Routers/Aruba/ArubaInstant.lmm.rb +144 -0
- data/Plugins/Platforms/GitHub.lmm.rb +57 -0
- data/Plugins/Platforms/GoDaddy/GoDaddy.lmm.rb +83 -0
- data/Plugins/Platforms/GoDaddy/zone.txt.erb +13 -0
- data/Plugins/Platforms/porkbun.lmm.rb +129 -0
- data/Plugins/Platforms/porkbun_spec.rb +110 -0
- data/Plugins/Services/DNS/AmberBit.lmm.rb +14 -0
- data/Plugins/Services/DNS/ArubaItDNS.lmm.rb +14 -0
- data/Plugins/Services/DNS/NICLV.lmm.rb +18 -0
- data/Plugins/Services/DNS/PowerDNS.lmm.rb +261 -0
- data/Plugins/Services/DNS/tonic.lmm.rb +126 -0
- data/README.md +337 -0
- data/Rakefile +15 -0
- data/UNLICENSE +24 -0
- data/bin/configlmm +7 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/ConfigLMM/Framework/plugins/dns.rb +63 -0
- data/lib/ConfigLMM/Framework/plugins/errors.rb +23 -0
- data/lib/ConfigLMM/Framework/plugins/nginxApp.rb +55 -0
- data/lib/ConfigLMM/Framework/plugins/plugin.rb +167 -0
- data/lib/ConfigLMM/Framework/plugins/ssh.rb +37 -0
- data/lib/ConfigLMM/Framework/plugins/store.rb +57 -0
- data/lib/ConfigLMM/Framework/plugins.rb +5 -0
- data/lib/ConfigLMM/Framework/registrator.rb +32 -0
- data/lib/ConfigLMM/Framework.rb +9 -0
- data/lib/ConfigLMM/LMM/plugins.rb +5 -0
- data/lib/ConfigLMM/LMM.rb +8 -0
- data/lib/ConfigLMM/cli.rb +161 -0
- data/lib/ConfigLMM/command.rb +53 -0
- data/lib/ConfigLMM/commands/build.rb +41 -0
- data/lib/ConfigLMM/commands/cleanup.rb +30 -0
- data/lib/ConfigLMM/commands/configsCommand.rb +167 -0
- data/lib/ConfigLMM/commands/deploy.rb +39 -0
- data/lib/ConfigLMM/commands/diff.rb +45 -0
- data/lib/ConfigLMM/commands/list.rb +15 -0
- data/lib/ConfigLMM/commands/refresh.rb +46 -0
- data/lib/ConfigLMM/commands/types.rb +35 -0
- data/lib/ConfigLMM/commands/validate.rb +49 -0
- data/lib/ConfigLMM/context.rb +52 -0
- data/lib/ConfigLMM/io/configList.rb +98 -0
- data/lib/ConfigLMM/io/path.rb +48 -0
- data/lib/ConfigLMM/io/source.rb +47 -0
- data/lib/ConfigLMM/io.rb +2 -0
- data/lib/ConfigLMM/state.rb +78 -0
- data/lib/ConfigLMM/utils/filters.rb +126 -0
- data/lib/ConfigLMM/version.rb +5 -0
- data/lib/ConfigLMM.rb +6 -0
- data/sig/ConfigLMM.rbs +4 -0
- metadata +485 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
module ConfigLMM
|
|
3
|
+
module LMM
|
|
4
|
+
class Mastodon < Framework::NginxApp
|
|
5
|
+
|
|
6
|
+
def actionMastodonBuild(id, target, state, context, options)
|
|
7
|
+
writeNginxConfig(__dir__, 'Mastodon', id, target, state, context, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def actionMastodonDiff(id, target, activeState, context, options)
|
|
11
|
+
# TODO
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def actionMastodonDeploy(id, target, activeState, context, options)
|
|
15
|
+
if !target['Location'] || target['Location'] == '@me'
|
|
16
|
+
deployNginxConfig(id, target, activeState, context, options)
|
|
17
|
+
activeState['Location'] = '@me'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
server {
|
|
3
|
+
<% if !config['TLS'] %>
|
|
4
|
+
listen <%= config['Port'] %>;
|
|
5
|
+
listen [::]:<%= config['Port'] %>;
|
|
6
|
+
<% else %>
|
|
7
|
+
listen <%= config['Port'] %> ssl;
|
|
8
|
+
listen [::]:<%= config['Port'] %> ssl;
|
|
9
|
+
http2 on;
|
|
10
|
+
include config-lmm/ssl.conf;
|
|
11
|
+
<% end %>
|
|
12
|
+
|
|
13
|
+
# For the federation port
|
|
14
|
+
#listen 8448 ssl http2 default_server;
|
|
15
|
+
#listen [::]:8448 ssl http2 default_server;
|
|
16
|
+
|
|
17
|
+
server_name <%= config['Domain'] %>;
|
|
18
|
+
|
|
19
|
+
access_log /var/log/nginx/matrix.access.log;
|
|
20
|
+
error_log /var/log/nginx/matrix.error.log;
|
|
21
|
+
|
|
22
|
+
include config-lmm/private.conf;
|
|
23
|
+
include config-lmm/errors.conf;
|
|
24
|
+
|
|
25
|
+
location ~ ^(/_matrix|/_synapse/client) {
|
|
26
|
+
# note: do not add a path (even a single /) after the port in `proxy_pass`,
|
|
27
|
+
# otherwise nginx will canonicalise the URI and cause signature verification
|
|
28
|
+
# errors.
|
|
29
|
+
proxy_pass http://localhost:8008;
|
|
30
|
+
include config-lmm/proxy.conf;
|
|
31
|
+
|
|
32
|
+
# Nginx by default only allows file uploads up to 1M in size
|
|
33
|
+
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
|
|
34
|
+
client_max_body_size 50M;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
module ConfigLMM
|
|
3
|
+
module LMM
|
|
4
|
+
class Matrix < Framework::NginxApp
|
|
5
|
+
|
|
6
|
+
def actionMatrixBuild(id, target, state, context, options)
|
|
7
|
+
writeNginxConfig(__dir__, 'Matrix', id, target, state, context, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def actionMatrixDiff(id, target, activeState, context, options)
|
|
11
|
+
# TODO
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def actionMatrixDeploy(id, target, activeState, context, options)
|
|
15
|
+
if !target['Location'] || target['Location'] == '@me'
|
|
16
|
+
deployNginxConfig(id, target, activeState, context, options)
|
|
17
|
+
activeState['Location'] = '@me'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
upstream netdata {
|
|
3
|
+
server 127.0.0.1:19999;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
server {
|
|
7
|
+
<% if !config['TLS'] %>
|
|
8
|
+
listen <%= config['Port'] %>;
|
|
9
|
+
listen [::]:<%= config['Port'] %>;
|
|
10
|
+
<% else %>
|
|
11
|
+
listen <%= config['Port'] %> ssl;
|
|
12
|
+
listen [::]:<%= config['Port'] %> ssl;
|
|
13
|
+
http2 on;
|
|
14
|
+
include config-lmm/ssl.conf;
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
server_name <%= config['Domain'] %>;
|
|
18
|
+
|
|
19
|
+
access_log /var/log/nginx/netdata.access.log;
|
|
20
|
+
error_log /var/log/nginx/netdata.error.log;
|
|
21
|
+
|
|
22
|
+
include config-lmm/private.conf;
|
|
23
|
+
include config-lmm/errors.conf;
|
|
24
|
+
|
|
25
|
+
location /stub_status {
|
|
26
|
+
stub_status;
|
|
27
|
+
allow 127.0.0.0/8;
|
|
28
|
+
allow ::1/128;
|
|
29
|
+
include config-lmm/private.conf;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
location / {
|
|
33
|
+
root /usr/share/nginx/html;
|
|
34
|
+
include config-lmm/proxy.conf;
|
|
35
|
+
proxy_pass http://netdata;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
module ConfigLMM
|
|
3
|
+
module LMM
|
|
4
|
+
class Netdata < Framework::NginxApp
|
|
5
|
+
|
|
6
|
+
def actionNetdataBuild(id, target, state, context, options)
|
|
7
|
+
writeNginxConfig(__dir__, 'Netdata', id, target, state, context, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def actionNetdataDiff(id, target, activeState, context, options)
|
|
11
|
+
# TODO
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def actionNetdataDeploy(id, target, activeState, context, options)
|
|
15
|
+
if !target['Location'] || target['Location'] == '@me'
|
|
16
|
+
deployNginxConfig(id, target, activeState, context, options)
|
|
17
|
+
activeState['Location'] = '@me'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
upstream nextcloud
|
|
5
|
+
{
|
|
6
|
+
server unix:/run/php-fpm/nextcloud.sock;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
server
|
|
10
|
+
{
|
|
11
|
+
<% if !config['TLS'] %>
|
|
12
|
+
listen <%= config['Port'] %>;
|
|
13
|
+
listen [::]:<%= config['Port'] %>;
|
|
14
|
+
<% else %>
|
|
15
|
+
listen <%= config['Port'] %> ssl;
|
|
16
|
+
listen [::]:<%= config['Port'] %> ssl;
|
|
17
|
+
http2 on;
|
|
18
|
+
include config-lmm/ssl.conf;
|
|
19
|
+
<% end %>
|
|
20
|
+
|
|
21
|
+
<%= config['Domain'] %>;
|
|
22
|
+
|
|
23
|
+
access_log /var/log/nginx/nextcloud.access.log;
|
|
24
|
+
error_log /var/log/nginx/nextcloud.error.log;
|
|
25
|
+
|
|
26
|
+
root /usr/share/webapps/nextcloud;
|
|
27
|
+
|
|
28
|
+
include config-lmm/private.conf;
|
|
29
|
+
include config-lmm/errors.conf;
|
|
30
|
+
|
|
31
|
+
# set max upload size and increase upload timeout:
|
|
32
|
+
client_max_body_size 512M;
|
|
33
|
+
client_body_timeout 300s;
|
|
34
|
+
fastcgi_buffers 64 4K;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# The settings allows you to optimize the HTTP2 bandwidth.
|
|
38
|
+
# See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
|
|
39
|
+
# for tuning hints
|
|
40
|
+
client_body_buffer_size 512k;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# HTTP response headers borrowed from Nextcloud `.htaccess`
|
|
44
|
+
add_header Referrer-Policy "no-referrer" always;
|
|
45
|
+
add_header X-Content-Type-Options "nosniff" always;
|
|
46
|
+
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
47
|
+
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
|
48
|
+
add_header X-Robots-Tag "noindex, nofollow" always;
|
|
49
|
+
add_header X-XSS-Protection "1; mode=block" always;
|
|
50
|
+
|
|
51
|
+
# Specify how to handle directories -- specifying `/index.php$request_uri`
|
|
52
|
+
# here as the fallback means that Nginx always exhibits the desired behaviour
|
|
53
|
+
# when a client requests a path that corresponds to a directory that exists
|
|
54
|
+
# on the server. In particular, if that directory contains an index.php file,
|
|
55
|
+
# that file is correctly served; if it doesn't, then the request is passed to
|
|
56
|
+
# the front-end controller. This consistent behaviour means that we don't need
|
|
57
|
+
# to specify custom rules for certain paths (e.g. images and other assets,
|
|
58
|
+
# `/updater`, `/ocs-provider`), and thus
|
|
59
|
+
# `try_files $uri $uri/ /index.php$request_uri`
|
|
60
|
+
# always provides the desired behaviour.
|
|
61
|
+
index index.php index.html /index.php$request_uri;
|
|
62
|
+
|
|
63
|
+
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
|
|
64
|
+
location = / {
|
|
65
|
+
if ( $http_user_agent ~ ^DavClnt ) {
|
|
66
|
+
return 302 /remote.php/webdav/$is_args$args;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
location = /robots.txt {
|
|
71
|
+
allow all;
|
|
72
|
+
log_not_found off;
|
|
73
|
+
access_log off;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# Make a regex exception for `/.well-known` so that clients can still
|
|
77
|
+
# access it despite the existence of the regex rule
|
|
78
|
+
# `location ~ /(\.|autotest|...)` which would otherwise handle requests
|
|
79
|
+
# for `/.well-known`.
|
|
80
|
+
location ^~ /.well-known {
|
|
81
|
+
# The rules in this block are an adaptation of the rules
|
|
82
|
+
# in `.htaccess` that concern `/.well-known`.
|
|
83
|
+
|
|
84
|
+
location = /.well-known/carddav { return 301 /remote.php/dav/; }
|
|
85
|
+
location = /.well-known/caldav { return 301 /remote.php/dav/; }
|
|
86
|
+
|
|
87
|
+
location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
|
|
88
|
+
location /.well-known/pki-validation { try_files $uri $uri/ =404; }
|
|
89
|
+
|
|
90
|
+
# Let Nextcloud's API for `/.well-known` URIs handle all other
|
|
91
|
+
# requests by passing them to the front-end controller.
|
|
92
|
+
return 301 /index.php$request_uri;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Rules borrowed from `.htaccess` to hide certain paths from clients
|
|
96
|
+
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
|
|
97
|
+
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
|
|
98
|
+
|
|
99
|
+
# Ensure this block, which passes PHP files to the PHP process, is above the blocks
|
|
100
|
+
# which handle static assets (as seen below). If this block is not declared first,
|
|
101
|
+
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
|
|
102
|
+
# to the URI, resulting in a HTTP 500 error response.
|
|
103
|
+
location ~ \.php(?:$|/)
|
|
104
|
+
{
|
|
105
|
+
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
|
|
106
|
+
fastcgi_param front_controller_active true; # Enable pretty urls
|
|
107
|
+
|
|
108
|
+
fastcgi_pass nextcloud;
|
|
109
|
+
include fastcgi.conf;
|
|
110
|
+
|
|
111
|
+
# Required for legacy support
|
|
112
|
+
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;
|
|
113
|
+
|
|
114
|
+
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
|
115
|
+
set $path_info $fastcgi_path_info;
|
|
116
|
+
|
|
117
|
+
try_files $fastcgi_script_name =404;
|
|
118
|
+
|
|
119
|
+
include fastcgi_params;
|
|
120
|
+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
121
|
+
fastcgi_param PATH_INFO $path_info;
|
|
122
|
+
fastcgi_param HTTPS on;
|
|
123
|
+
fastcgi_param HTTP_PROXY "";
|
|
124
|
+
fastcgi_buffer_size 16k;
|
|
125
|
+
fastcgi_buffers 4 16k;
|
|
126
|
+
#fastcgi_connect_timeout 300;
|
|
127
|
+
fastcgi_send_timeout 300;
|
|
128
|
+
fastcgi_read_timeout 300;
|
|
129
|
+
|
|
130
|
+
fastcgi_intercept_errors off;
|
|
131
|
+
fastcgi_request_buffering off;
|
|
132
|
+
|
|
133
|
+
fastcgi_max_temp_file_size 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# Serve static files
|
|
137
|
+
location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
|
|
138
|
+
try_files $uri /index.php$request_uri;
|
|
139
|
+
# HTTP response headers borrowed from Nextcloud `.htaccess`
|
|
140
|
+
add_header Cache-Control "public, max-age=15778463$assetImmutable";
|
|
141
|
+
add_header Referrer-Policy "no-referrer" always;
|
|
142
|
+
add_header X-Content-Type-Options "nosniff" always;
|
|
143
|
+
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
144
|
+
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
|
145
|
+
add_header X-Robots-Tag "noindex, nofollow" always;
|
|
146
|
+
add_header X-XSS-Protection "1; mode=block" always;
|
|
147
|
+
access_log off; # Optional: Don't log access to assets
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
location ~ \.woff2?$ {
|
|
151
|
+
try_files $uri /index.php$request_uri;
|
|
152
|
+
expires 7d; # Cache-Control policy borrowed from `.htaccess`
|
|
153
|
+
access_log off; # Optional: Don't log access to assets
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# Rule borrowed from `.htaccess`
|
|
157
|
+
location /remote {
|
|
158
|
+
return 301 /remote.php$request_uri;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
location / {
|
|
162
|
+
try_files $uri $uri/ /index.php$request_uri;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
module ConfigLMM
|
|
3
|
+
module LMM
|
|
4
|
+
class Nextcloud < Framework::NginxApp
|
|
5
|
+
|
|
6
|
+
def actionNextcloudBuild(id, target, state, context, options)
|
|
7
|
+
writeNginxConfig(__dir__, 'Nextcloud', id, target, state, context, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def actionNextcloudDiff(id, target, activeState, context, options)
|
|
11
|
+
# TODO
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def actionNextcloudDeploy(id, target, activeState, context, options)
|
|
15
|
+
if !target['Location'] || target['Location'] == '@me'
|
|
16
|
+
deployNginxConfig(id, target, activeState, context, options)
|
|
17
|
+
activeState['Location'] = '@me'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
# add one directive for each http status code
|
|
3
|
+
error_page 301 /_errors_/HTTP301.$errorExtension;
|
|
4
|
+
error_page 302 /_errors_/HTTP302.$errorExtension;
|
|
5
|
+
error_page 303 /_errors_/HTTP303.$errorExtension;
|
|
6
|
+
error_page 307 /_errors_/HTTP307.$errorExtension;
|
|
7
|
+
error_page 308 /_errors_/HTTP308.$errorExtension;
|
|
8
|
+
error_page 400 /_errors_/HTTP400.$errorExtension;
|
|
9
|
+
error_page 401 /_errors_/HTTP401.$errorExtension;
|
|
10
|
+
# error_page 402 /_errors_/HTTP402.$errorExtension;
|
|
11
|
+
error_page 403 /_errors_/HTTP403.$errorExtension;
|
|
12
|
+
error_page 404 /_errors_/HTTP404.$errorExtension;
|
|
13
|
+
error_page 405 /_errors_/HTTP405.$errorExtension;
|
|
14
|
+
error_page 500 /_errors_/HTTP500.$errorExtension;
|
|
15
|
+
error_page 501 /_errors_/HTTP501.$errorExtension;
|
|
16
|
+
error_page 502 /_errors_/HTTP502.$errorExtension;
|
|
17
|
+
error_page 503 /_errors_/HTTP503.$errorExtension;
|
|
18
|
+
error_page 504 /_errors_/HTTP504.$errorExtension;
|
|
19
|
+
error_page 520 /_errors_/HTTP520.$errorExtension;
|
|
20
|
+
error_page 521 /_errors_/HTTP521.$errorExtension;
|
|
21
|
+
error_page 533 /_errors_/HTTP533.$errorExtension;
|
|
22
|
+
|
|
23
|
+
location /_errors_/ {
|
|
24
|
+
include config/public.conf;
|
|
25
|
+
|
|
26
|
+
alias /srv/http/errors/;
|
|
27
|
+
internal;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
add_header Location $upstream_http_location;
|
|
31
|
+
add_header Set-Cookie $upstream_http_set_cookie;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
proxy_http_version 1.1;
|
|
3
|
+
|
|
4
|
+
proxy_set_header Host $host;
|
|
5
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
6
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
7
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
8
|
+
proxy_set_header X-Forwarded-Protocol $scheme;
|
|
9
|
+
proxy_set_header X-Forwarded-Host $http_host;
|
|
10
|
+
|
|
11
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
12
|
+
proxy_set_header Connection $connectionUpgrade;
|
|
13
|
+
|
|
14
|
+
# proxy_set_header Proxy "";
|
|
15
|
+
proxy_pass_header Server;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
ssl_session_timeout 1d;
|
|
3
|
+
ssl_session_cache shared:SSL:10m; # about 40000 sessions
|
|
4
|
+
ssl_session_tickets off;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# modern configuration
|
|
8
|
+
ssl_protocols TLSv1.3;
|
|
9
|
+
ssl_prefer_server_ciphers off;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
|
|
13
|
+
add_header Strict-Transport-Security "max-age=63072000" always;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# OCSP stapling
|
|
17
|
+
ssl_stapling on;
|
|
18
|
+
ssl_stapling_verify on;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
server {
|
|
3
|
+
listen 80;
|
|
4
|
+
listen [::]:80;
|
|
5
|
+
server_name _;
|
|
6
|
+
|
|
7
|
+
include config-lmm/errors.conf;
|
|
8
|
+
|
|
9
|
+
deny all;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
server {
|
|
13
|
+
listen 443 ssl reuseport;
|
|
14
|
+
listen [::]:443 ssl reuseport;
|
|
15
|
+
http2 on;
|
|
16
|
+
|
|
17
|
+
server_name _;
|
|
18
|
+
|
|
19
|
+
deny all;
|
|
20
|
+
|
|
21
|
+
ssl_early_data on;
|
|
22
|
+
|
|
23
|
+
ssl_certificate "/etc/letsencrypt/live/<%= certName %>/fullchain.pem";
|
|
24
|
+
ssl_certificate_key "/etc/letsencrypt/live/<%= certName %>/privkey.pem";
|
|
25
|
+
ssl_trusted_certificate "/etc/letsencrypt/live/<%= certName %>/chain.pem";
|
|
26
|
+
|
|
27
|
+
include config-lmm/errors.conf;
|
|
28
|
+
include config-lmm/security.conf;
|
|
29
|
+
include config-lmm/ssl.conf;
|
|
30
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
load_module "/usr/lib/nginx/modules/ngx_http_passenger_module.so";
|
|
3
|
+
#load_module "/usr/lib/nginx/modules/ngx_http_stub_status_module.so";
|
|
4
|
+
|
|
5
|
+
#user http;
|
|
6
|
+
worker_processes 4;
|
|
7
|
+
|
|
8
|
+
#error_log logs/error.log;
|
|
9
|
+
#error_log logs/error.log notice;
|
|
10
|
+
#error_log logs/error.log info;
|
|
11
|
+
error_log /var/log/nginx/error.log info;
|
|
12
|
+
|
|
13
|
+
#pid logs/nginx.pid;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
events {
|
|
17
|
+
worker_connections 1024;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
http {
|
|
22
|
+
include mime.types;
|
|
23
|
+
default_type application/octet-stream;
|
|
24
|
+
server_tokens off;
|
|
25
|
+
|
|
26
|
+
types_hash_max_size 4096;
|
|
27
|
+
types_hash_bucket_size 64;
|
|
28
|
+
proxy_headers_hash_max_size 512;
|
|
29
|
+
proxy_headers_hash_bucket_size 128;
|
|
30
|
+
|
|
31
|
+
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
32
|
+
# '$status $body_bytes_sent "$http_referer" '
|
|
33
|
+
# '"$http_user_agent" "$http_x_forwarded_for"';
|
|
34
|
+
|
|
35
|
+
#access_log logs/access.log main;
|
|
36
|
+
|
|
37
|
+
sendfile on;
|
|
38
|
+
tcp_nopush on;
|
|
39
|
+
resolver 127.0.0.53;
|
|
40
|
+
|
|
41
|
+
gzip on;
|
|
42
|
+
gzip_vary on;
|
|
43
|
+
gzip_proxied any;
|
|
44
|
+
gzip_comp_level 6;
|
|
45
|
+
gzip_min_length 256;
|
|
46
|
+
|
|
47
|
+
# do not remove ETag headers
|
|
48
|
+
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
|
|
49
|
+
|
|
50
|
+
gzip_types application/atom+xml text/javascript text/xml application/xml+rss application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
charset utf-8;
|
|
54
|
+
charset_types text/css text/plain text/xml text/javascript text/vnd.wap.wml application/json application/javascript application/xml application/xml+rss application/rss+xm image/svg+xml;
|
|
55
|
+
proxy_intercept_errors on;
|
|
56
|
+
fastcgi_intercept_errors on;
|
|
57
|
+
|
|
58
|
+
map $http_accept $errorExtension
|
|
59
|
+
{
|
|
60
|
+
default html;
|
|
61
|
+
~application/json json;
|
|
62
|
+
~application/activity+json json;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
map $http_upgrade $connectionUpgrade
|
|
66
|
+
{
|
|
67
|
+
default upgrade;
|
|
68
|
+
'' '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
|
|
72
|
+
map $arg_v $assetImmutable
|
|
73
|
+
{
|
|
74
|
+
"" "";
|
|
75
|
+
default ", immutable";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
passenger_ruby /usr/bin/ruby;
|
|
79
|
+
passenger_root /usr/lib/passenger;
|
|
80
|
+
|
|
81
|
+
root /srv/http/root;
|
|
82
|
+
|
|
83
|
+
include /etc/nginx/main.conf;
|
|
84
|
+
|
|
85
|
+
# Load modular configuration files from the /etc/nginx/servers directory.
|
|
86
|
+
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
|
87
|
+
# for more information.
|
|
88
|
+
include /etc/nginx/servers/*.conf;
|
|
89
|
+
include /etc/nginx/servers-lmm/*.conf;
|
|
90
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
module ConfigLMM
|
|
3
|
+
module LMM
|
|
4
|
+
class Nginx < Framework::NginxApp
|
|
5
|
+
|
|
6
|
+
CONFIG_DIR = '/etc/nginx/'
|
|
7
|
+
HTTP_DIR = '/srv/http/'
|
|
8
|
+
|
|
9
|
+
def actionNginxBuild(id, target, activeState, context, options)
|
|
10
|
+
dir = options['output'] + '/nginx/'
|
|
11
|
+
mkdir(dir, options[:dry])
|
|
12
|
+
copy(__dir__ + '/config-lmm', dir, options[:dry])
|
|
13
|
+
# TODO, maybe evaluate them as template?
|
|
14
|
+
copy(__dir__ + '/nginx.conf', dir, options[:dry])
|
|
15
|
+
copy(__dir__ + '/main.conf', dir, options[:dry])
|
|
16
|
+
mkdir(options['output'] + HTTP_DIR + 'root', options[:dry])
|
|
17
|
+
mkdir(options['output'] + HTTP_DIR + 'errors', options[:dry])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# TODO
|
|
21
|
+
# def actionNginxDiff(id, target, activeState, context, options)
|
|
22
|
+
# I think we need nginx config parser to implement this
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
def actionNginxDeploy(id, target, activeState, context, options)
|
|
26
|
+
dir = options['output'] + '/nginx/'
|
|
27
|
+
|
|
28
|
+
if !target['Location'] || target['Location'] == '@me'
|
|
29
|
+
copy(dir + '/config-lmm', CONFIG_DIR, options[:dry])
|
|
30
|
+
copyNotPresent(dir + '/nginx.conf', CONFIG_DIR, options[:dry])
|
|
31
|
+
copyNotPresent(dir + '/main.conf', CONFIG_DIR, options[:dry])
|
|
32
|
+
copyNotPresent(dir + '/servers-lmm', CONFIG_DIR, options['dry'])
|
|
33
|
+
mkdir(HTTP_DIR + 'root', options[:dry])
|
|
34
|
+
mkdir(HTTP_DIR + 'errors', options[:dry])
|
|
35
|
+
end
|
|
36
|
+
# Consider:
|
|
37
|
+
# * Deploy on current host
|
|
38
|
+
# * Deploy on remote host thru SSH (eg. VPS)
|
|
39
|
+
# * Using already existing solution like Chef/Puppet/Ansible/etc
|
|
40
|
+
# * Provision from some Cloud provider
|
|
41
|
+
# We implement this as we go - what people actually use
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def actionNginxProxyBuild(id, target, activeState, context, options)
|
|
45
|
+
updateTargetConfig(target)
|
|
46
|
+
|
|
47
|
+
template = ERB.new(File.read(__dir__ + '/proxy.conf.erb'))
|
|
48
|
+
renderTemplate(template, target, options['output'] + '/nginx/servers-lmm/' + target['Name'] + '.conf', options)
|
|
49
|
+
|
|
50
|
+
actionNginxBuild(id, target, activeState, context, options)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def actionNginxProxyDeploy(id, target, activeState, context, options)
|
|
54
|
+
if !target['Location'] || target['Location'] == '@me'
|
|
55
|
+
deployNginxConfig(id, target, activeState, context, options)
|
|
56
|
+
activeState['Location'] = '@me'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# DON'T EDIT THIS FILE DIRECTLY
|
|
2
|
+
# IT WAS GENERATED BY CONFIGLMM
|
|
3
|
+
|
|
4
|
+
server {
|
|
5
|
+
<% if !config['TLS'] %>
|
|
6
|
+
listen <%= config['Port'] %>;
|
|
7
|
+
listen [::]:<%= config['Port'] %>;
|
|
8
|
+
<% else %>
|
|
9
|
+
listen <%= config['Port'] %> ssl;
|
|
10
|
+
listen [::]:<%= config['Port'] %> ssl;
|
|
11
|
+
http2 on;
|
|
12
|
+
include config-lmm/ssl.conf;
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
15
|
+
server_name <%= config['Domain'] %>;
|
|
16
|
+
|
|
17
|
+
access_log /var/log/nginx/<%= config['Name'].downcase %>.access.log;
|
|
18
|
+
error_log /var/log/nginx/<%= config['Name'].downcase %>.error.log;
|
|
19
|
+
|
|
20
|
+
include config-lmm/errors.conf;
|
|
21
|
+
|
|
22
|
+
<% if config['Private'] %>
|
|
23
|
+
include config-lmm/private.conf;
|
|
24
|
+
<% end %>
|
|
25
|
+
|
|
26
|
+
location / {
|
|
27
|
+
proxy_pass <%= config['Proxy'] %>;
|
|
28
|
+
|
|
29
|
+
include config-lmm/proxy.conf;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
upstream odoo {
|
|
3
|
+
server 127.0.0.1:8069;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
server {
|
|
7
|
+
|
|
8
|
+
<% if !config['TLS'] %>
|
|
9
|
+
listen <%= config['Port'] %>;
|
|
10
|
+
listen [::]:<%= config['Port'] %>;
|
|
11
|
+
<% else %>
|
|
12
|
+
listen <%= config['Port'] %> ssl;
|
|
13
|
+
listen [::]:<%= config['Port'] %> ssl;
|
|
14
|
+
http2 on;
|
|
15
|
+
include config/ssl.conf;
|
|
16
|
+
<% end %>
|
|
17
|
+
|
|
18
|
+
server_name <%= config['Domain'] %>;
|
|
19
|
+
|
|
20
|
+
root /usr/share/nginx/html;
|
|
21
|
+
index index.html index.htm;
|
|
22
|
+
access_log /var/log/nginx/odoo.access.log;
|
|
23
|
+
error_log /var/log/nginx/odoo.error.log;
|
|
24
|
+
|
|
25
|
+
include config/private.conf;
|
|
26
|
+
include config/errors.conf;
|
|
27
|
+
|
|
28
|
+
location / {
|
|
29
|
+
proxy_pass http://odoo;
|
|
30
|
+
# force timeouts if the backend dies
|
|
31
|
+
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
32
|
+
proxy_redirect off;
|
|
33
|
+
|
|
34
|
+
include config/proxy.conf;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# cache some static data in memory for 60mins
|
|
38
|
+
location ~* /web/static/ {
|
|
39
|
+
proxy_cache_valid 200 60m;
|
|
40
|
+
proxy_buffering on;
|
|
41
|
+
expires 864000;
|
|
42
|
+
proxy_pass http://odoo;
|
|
43
|
+
}
|
|
44
|
+
}
|