From 56ffb39cc527233fa5e2c5940ba6ea8f91ff003e Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Mon, 28 Oct 2019 18:10:50 +0100
Subject: [PATCH] nginx proxy, gitea proxied
---
services/gitea.spec | 2 +-
services/nginx.spec | 3 ++-
templates/nginx.conf.j2 | 18 ++++++++++++++++--
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/services/gitea.spec b/services/gitea.spec
index 7a5cdef..d9e6e29 100644
--- a/services/gitea.spec
+++ b/services/gitea.spec
@@ -1,5 +1,5 @@
command: gitea -C . -w . -c ./custom/conf/app.ini
-consumes: postgresql
+consumes: postgresql, http?
requires-domain: true
%directory ${SERVICE_ROOT}/custom/conf
diff --git a/services/nginx.spec b/services/nginx.spec
index 2d6fbf5..104dcc6 100644
--- a/services/nginx.spec
+++ b/services/nginx.spec
@@ -1,5 +1,6 @@
command: nginx -c ${SERVICE_ROOT}/nginx.conf
-provides: www
+consumes: http?
+provides: www, http
%directory ${SERVICE_ROOT}/
name: working directory
diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2
index 6f132ed..b1d2f5a 100644
--- a/templates/nginx.conf.j2
+++ b/templates/nginx.conf.j2
@@ -23,8 +23,8 @@ http {
{% for user in consumers["www"] %}
server {
- listen {{ port(user.id) }} ;
- listen [::]:{{ port(user.id) }} ;
+ listen {{ port(service.id) }} ;
+ listen [::]:{{ port(service.id) }} ;
server_name {{ user.domain }} ;
location / {
@@ -33,4 +33,18 @@ http {
}
{% endfor %}
+ {% for user in consumers["http"] %}
+ server {
+ listen {{ port(service.id) }};
+ listen [::]:{{ port(service.id) }};
+ server_name {{ user.domain }} *.{{ user.domain }};
+
+ location / {
+ proxy_set_header Host $host;
+ proxy_next_upstream_timeout 2s;
+ proxy_pass http://127.0.0.1:{{ port(user.id) }}/;
+ }
+ }
+ {% endfor %}
+
}