mirror of
https://github.com/hassio-addons/addon-grocy.git
synced 2025-05-05 03:31:30 +00:00
Refactor NGINX/PHP-FPM configuration (#115)
* Refactor NGINX/PHP-FPM configuration * Use default ingress port
This commit is contained in:
parent
db3bbe6e8c
commit
f720ccb0e3
12 changed files with 59 additions and 75 deletions
|
@ -6,11 +6,8 @@
|
||||||
"url": "https://github.com/hassio-addons/addon-grocy",
|
"url": "https://github.com/hassio-addons/addon-grocy",
|
||||||
"webui": "[PROTO:ssl]://[HOST]:[PORT:80]",
|
"webui": "[PROTO:ssl]://[HOST]:[PORT:80]",
|
||||||
"ingress": true,
|
"ingress": true,
|
||||||
"ingress_port": 1337,
|
|
||||||
"panel_icon": "mdi:cart",
|
"panel_icon": "mdi:cart",
|
||||||
"startup": "system",
|
|
||||||
"arch": ["aarch64", "amd64", "armhf", "armv7", "i386"],
|
"arch": ["aarch64", "amd64", "armhf", "armv7", "i386"],
|
||||||
"hassio_api": true,
|
|
||||||
"map": ["ssl"],
|
"map": ["ssl"],
|
||||||
"ports": {
|
"ports": {
|
||||||
"80/tcp": null
|
"80/tcp": null
|
||||||
|
|
|
@ -3,34 +3,22 @@
|
||||||
# Home Assistant Community Add-on: Grocy
|
# Home Assistant Community Add-on: Grocy
|
||||||
# Configures NGINX for use with Grocy
|
# Configures NGINX for use with Grocy
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
declare certfile
|
|
||||||
declare dns_host
|
|
||||||
declare ingress_entry
|
|
||||||
declare ingress_interface
|
|
||||||
declare keyfile
|
|
||||||
declare port
|
|
||||||
|
|
||||||
port=$(bashio::addon.port 80)
|
# Generate Ingress PHP-FPM configuration
|
||||||
if bashio::var.has_value "${port}"; then
|
bashio::var.json \
|
||||||
|
interface "$(bashio::addon.ip_address)" \
|
||||||
|
| tempio \
|
||||||
|
-template /etc/nginx/templates/ingress.gtpl \
|
||||||
|
-out /etc/nginx/servers/ingress.conf
|
||||||
|
|
||||||
|
# Generate direct access configuration, if enabled.
|
||||||
|
if bashio::var.has_value "$(bashio::addon.port 80)"; then
|
||||||
bashio::config.require.ssl
|
bashio::config.require.ssl
|
||||||
|
bashio::var.json \
|
||||||
if bashio::config.true 'ssl'; then
|
certfile "$(bashio::config 'certfile')" \
|
||||||
certfile=$(bashio::config 'certfile')
|
keyfile "$(bashio::config 'keyfile')" \
|
||||||
keyfile=$(bashio::config 'keyfile')
|
ssl "^$(bashio::config 'ssl')" \
|
||||||
|
| tempio \
|
||||||
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
|
-template /etc/nginx/templates/direct.gtpl \
|
||||||
sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf
|
-out /etc/nginx/servers/direct.conf
|
||||||
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf
|
|
||||||
else
|
|
||||||
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
ingress_interface=$(bashio::addon.ip_address)
|
|
||||||
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
|
|
||||||
|
|
||||||
ingress_entry=$(bashio::addon.ingress_entry)
|
|
||||||
sed -i "s#%%ingress_entry%%#${ingress_entry}#g" /etc/php7/php-fpm.d/ingress.conf
|
|
||||||
|
|
||||||
dns_host=$(bashio::dns.host)
|
|
||||||
sed -i "s/%%dns_host%%/${dns_host}/g" /etc/nginx/includes/resolver.conf
|
|
||||||
|
|
24
grocy/rootfs/etc/cont-init.d/php-fpm.sh
Normal file
24
grocy/rootfs/etc/cont-init.d/php-fpm.sh
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# Home Assistant Community Add-on: Grocy
|
||||||
|
# Configures PHP-FPM for use with Grocy
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# Generate Ingress configuration
|
||||||
|
bashio::var.json \
|
||||||
|
name "ingress" \
|
||||||
|
port "^9002" \
|
||||||
|
base "$(bashio::addon.ingress_entry)" \
|
||||||
|
| tempio \
|
||||||
|
-template /etc/php7/templates/php-fpm.gtpl \
|
||||||
|
-out /etc/php7/php-fpm.d/ingress.conf
|
||||||
|
|
||||||
|
# Generate direct access configuration, if enabled.
|
||||||
|
if bashio::var.has_value "$(bashio::addon.port 80)"; then
|
||||||
|
bashio::var.json \
|
||||||
|
name "www" \
|
||||||
|
port "^9001" \
|
||||||
|
| tempio \
|
||||||
|
-template /etc/php7/templates/php-fpm.gtpl \
|
||||||
|
-out /etc/php7/php-fpm.d/www.conf
|
||||||
|
fi
|
|
@ -1 +0,0 @@
|
||||||
resolver %%dns_host%%;
|
|
|
@ -16,13 +16,6 @@ pcre_jit on;
|
||||||
# Write error log to the add-on log.
|
# Write error log to the add-on log.
|
||||||
error_log /proc/1/fd/1 error;
|
error_log /proc/1/fd/1 error;
|
||||||
|
|
||||||
# Load allowed environment vars
|
|
||||||
env SUPERVISOR_TOKEN;
|
|
||||||
env DISABLE_HA_AUTHENTICATION;
|
|
||||||
|
|
||||||
# Load dynamic modules.
|
|
||||||
include /etc/nginx/modules/*.conf;
|
|
||||||
|
|
||||||
# Max num of simultaneous connections by a worker process.
|
# Max num of simultaneous connections by a worker process.
|
||||||
events {
|
events {
|
||||||
worker_connections 512;
|
worker_connections 512;
|
||||||
|
@ -50,7 +43,5 @@ http {
|
||||||
'' close;
|
'' close;
|
||||||
}
|
}
|
||||||
|
|
||||||
include /etc/nginx/includes/resolver.conf;
|
|
||||||
|
|
||||||
include /etc/nginx/servers/*.conf;
|
include /etc/nginx/servers/*.conf;
|
||||||
}
|
}
|
||||||
|
|
1
grocy/rootfs/etc/nginx/servers/.gitkeep
Normal file
1
grocy/rootfs/etc/nginx/servers/.gitkeep
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Without requirements or design, programming is the art of adding bugs to an empty text file. (Louis Srygley)
|
|
@ -1,14 +0,0 @@
|
||||||
server {
|
|
||||||
listen 80 default_server;
|
|
||||||
|
|
||||||
include /etc/nginx/includes/server_params.conf;
|
|
||||||
|
|
||||||
location ~ .php$ {
|
|
||||||
fastcgi_pass 127.0.0.1:9001;
|
|
||||||
fastcgi_read_timeout 900;
|
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
include /etc/nginx/includes/fastcgi_params.conf;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +1,19 @@
|
||||||
server {
|
server {
|
||||||
|
{{ if not .ssl }}
|
||||||
|
listen 80 default_server;
|
||||||
|
{{ else }}
|
||||||
listen 80 default_server ssl http2;
|
listen 80 default_server ssl http2;
|
||||||
|
{{ end }}
|
||||||
include /etc/nginx/includes/ssl_params.conf;
|
|
||||||
|
|
||||||
ssl_certificate /ssl/%%certfile%%;
|
|
||||||
ssl_certificate_key /ssl/%%keyfile%%;
|
|
||||||
|
|
||||||
include /etc/nginx/includes/server_params.conf;
|
include /etc/nginx/includes/server_params.conf;
|
||||||
|
|
||||||
|
{{ if .ssl }}
|
||||||
|
include /etc/nginx/includes/ssl_params.conf;
|
||||||
|
|
||||||
|
ssl_certificate /ssl/{{ .certfile }};
|
||||||
|
ssl_certificate_key /ssl/{{ .keyfile }};
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
location ~ .php$ {
|
location ~ .php$ {
|
||||||
fastcgi_pass 127.0.0.1:9001;
|
fastcgi_pass 127.0.0.1:9001;
|
||||||
fastcgi_read_timeout 900;
|
fastcgi_read_timeout 900;
|
|
@ -1,5 +1,5 @@
|
||||||
server {
|
server {
|
||||||
listen %%interface%%:1337 default_server;
|
listen {{ .interface }}:8099 default_server;
|
||||||
|
|
||||||
include /etc/nginx/includes/server_params.conf;
|
include /etc/nginx/includes/server_params.conf;
|
||||||
|
|
1
grocy/rootfs/etc/php7/php-fpm.d/.gitkeep
Normal file
1
grocy/rootfs/etc/php7/php-fpm.d/.gitkeep
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Without requirements or design, programming is the art of adding bugs to an empty text file. (Louis Srygley)
|
|
@ -1,11 +0,0 @@
|
||||||
[www]
|
|
||||||
user = nginx
|
|
||||||
group = nginx
|
|
||||||
listen = 127.0.0.1:9001
|
|
||||||
pm = dynamic
|
|
||||||
pm.max_children = 10
|
|
||||||
pm.start_servers = 3
|
|
||||||
pm.min_spare_servers = 2
|
|
||||||
pm.max_spare_servers = 5
|
|
||||||
pm.max_requests = 1024
|
|
||||||
clear_env = no
|
|
|
@ -1,7 +1,7 @@
|
||||||
[ingress]
|
[{{ .name }}]
|
||||||
user = nginx
|
user = nginx
|
||||||
group = nginx
|
group = nginx
|
||||||
listen = 127.0.0.1:9002
|
listen = 127.0.0.1:{{ .port }}
|
||||||
pm = dynamic
|
pm = dynamic
|
||||||
pm.max_children = 10
|
pm.max_children = 10
|
||||||
pm.start_servers = 3
|
pm.start_servers = 3
|
||||||
|
@ -9,4 +9,6 @@ pm.min_spare_servers = 2
|
||||||
pm.max_spare_servers = 5
|
pm.max_spare_servers = 5
|
||||||
pm.max_requests = 1024
|
pm.max_requests = 1024
|
||||||
clear_env = no
|
clear_env = no
|
||||||
env[GROCY_BASE_URL] = '%%ingress_entry%%'
|
{{ if .base }}
|
||||||
|
env[GROCY_BASE_URL] = '{{ .base }}'
|
||||||
|
{{ end }}
|
Loading…
Add table
Add a link
Reference in a new issue