aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2021-06-06 16:51:50 +0100
committerMiquel Lionel <lionelmiquel@sfr.fr>2021-06-06 16:51:50 +0100
commitc737d6aefe406ac52f4e2f913365efdede3f58a4 (patch)
tree7369bbdd5e04750d3f440d042d00ad9a6c338566
parent3b3c85e3221b7bf679c84b442fe1453fc8d83238 (diff)
downloadgpigeon-c737d6aefe406ac52f4e2f913365efdede3f58a4.tar.gz
gpigeon-c737d6aefe406ac52f4e2f913365efdede3f58a4.zip
add make vars to generate a nginx config
-rw-r--r--Makefile17
-rw-r--r--README.md3
-rw-r--r--config.def.mk5
-rw-r--r--nginx-example.conf34
4 files changed, 56 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 83d1f8c..98a8a8e 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,9 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi
$(MAKE) clean ; \
exit 1; \
fi
+
+
+
@if [ '${HAS_MAILSERVER}' == '1' ]; then \
printf "Local mail server setup. ${BOLD}Mail::Sendmail module will be used to send the mails${STOP}.\n"; \
else \
@@ -126,6 +129,10 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi
fi
@sed -e 's|has_mailserver_goes_here|$(HAS_MAILSERVER)|g' link-tmpl-template.cgi > link-tmpl.cgi
@sed -e 's|gpg_homedir_goes_here|$(_GPG_HOMEDIR)|g' link-tmpl-template.cgi > link-tmpl.cgi
+ @if test -n '$(WWWDOMAIN)' && test -n '$(WWWPREFIX)'; then\
+ $(MAKE) nginxconf;\
+ printf "Done generating $(WWWDOMAIN).conf for nginx.";\
+ fi
@printf "\nDone preparing files. You can now type\nsudo make install\nin your terminal.\n"
install:
@@ -137,12 +144,20 @@ install:
install -Dm600 link-tmpl.cgi $(DESTDIR)$(LINK_TEMPLATE_PATH)
install -Dm644 index.html favicon.ico styles.css -t $(DESTDIR)$(WWWPREFIX)/
install -Dm755 merci/* -t $(DESTDIR)$(PREFIX)/merci/
+ @if test -e '$(WWWDOMAIN).conf'; then\
+ printf "\nInstalling $(WWWDOMAIN).conf into $(NGINXCONFDIR)\n";\
+ install -Dm644 $(WWWDOMAIN).conf -t $(DESTDIR)$(NGINXCONFDIR);\
+ fi
+nginxconf: nginx-example.conf
+ @sed -e 's|wwwpath_goes_here|$(WWWPREFIX)|g;s|domain_goes_here|$(WWWDOMAIN)|g' nginx-example.conf > $(WWWDOMAIN).conf ;\
+
+
uninstall:
rm -rf $(DESTDIR)$(PREFIX)
rm -rf $(DESTDIR)$(WWWPREFIX)
clean:
- rm -f genpass.txt gpg.txt link-tmpl.cgi gpigeon.cgi
+ rm -f genpass.txt gpg.txt link-tmpl.cgi gpigeon.cgi $(WWWDOMAIN).conf
.PHONY: clean install uninstall
diff --git a/README.md b/README.md
index 14234c2..5ad4283 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,6 @@ server {
fastcgi_pass unix:/run/fcgiwrap.sock;
include /etc/nginx/fastcgi_params;
}
-
- include errorpages.conf;
}
```
+You can also tune the `WWWDOMAIN` and `NGINXCONFDIR` variable in your `config.mk` to have it generated for you when running `make`.
diff --git a/config.def.mk b/config.def.mk
index 5917230..9c03cd6 100644
--- a/config.def.mk
+++ b/config.def.mk
@@ -23,3 +23,8 @@ MAILSENDER =# the mailer address that'll send you the encrypted mails
MAILSENDER_PW =# password for the mailer address
SMTP_DOMAIN =# smtp domain pour the mailer
SMTP_PORT =# smtp port for the mailer
+
+#optional, domain to generate nginx config for
+#and where to put the config
+WWWDOMAIN=
+NGINXCONFDIR=/etc/nginx/sites-enabled
diff --git a/nginx-example.conf b/nginx-example.conf
new file mode 100644
index 0000000..97e5027
--- /dev/null
+++ b/nginx-example.conf
@@ -0,0 +1,34 @@
+server {
+ listen 80;
+ server_name domain_goes_here;
+
+ location / {
+ return 301 https://$host$request_uri;
+ }
+}
+
+server {
+ listen 443 ssl http2;
+
+ root wwwpath_goes_here;
+ server_name domain_goes_here;
+ ssl_certificate /etc/letsencrypt/live/domain_goes_here/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/domain_goes_here/privkey.pem;
+ error_log /var/log/gpigeon.log;
+ index index.html index.htm;
+
+ location = /cgi-bin/gpigeon.cgi {
+ ssi off;
+ gzip off;
+ fastcgi_pass unix:/run/fcgiwrap.sock;
+ include /etc/nginx/fastcgi_params;
+ }
+
+ location ~ ^/cgi-bin/l/(.*).cgi$ {
+ ssi off;
+ gzip off;
+ fastcgi_pass unix:/run/fcgiwrap.sock;
+ include /etc/nginx/fastcgi_params;
+ }
+}
+