leafac / kill-the-newsletter

Convert email newsletters into Atom feeds
https://kill-the-newsletter.com
MIT License
2.4k stars 115 forks source link

Support for own reverse proxy #53

Closed ericfischerbav closed 2 years ago

ericfischerbav commented 2 years ago

I'd like to install the application within my Docker environment.

There, I use a nginx reverse proxy for redirecting the requests from the subdomain to the corresponding service, since the proxy is opening the ports 80 and 443. The proxy is also handling the certificates for https.

Is it possible to run the application just on port 80? The port for the email server can be opened seperatly.

Thanks in advance.

BTW: If you like I can provide my Dockerfile afterwards.

leafac commented 2 years ago

Hi @ericfischerbav,

I’m glad you’re self-hosting Kill the Newsletter!

Is it possible to run the application just on port 80?

Yes, you may do that by changing the configuration file to not start the reverse proxy. Instead of these lines you’d have something like webApplication.listen(80).

BTW: If you like I can provide my Dockerfile afterwards.

Thanks, that’s very nice of you to offer, but I prefer to have a single recommended installation method.

Feel free to reopen the issue in case you run into other problems.

onnyyonn commented 2 years ago

@ericfischerbav Can you please share the Nginx reverse proxy config and the changes you made to kill-the-newsletter configuration file to make it work?

ericfischerbav commented 2 years ago

Unfortunatly, I deleted my configuration because of other problem related to my server.

But I think the configuration.js has to look like this:

module.exports = async (require) => {
  const path = require("path");
  const express = require("express");
  const AutoEncrypt = require("@small-tech/auto-encrypt");
  const killTheNewsletter = require(".").default;

  const { webApplication, emailApplication } = killTheNewsletter(
    path.join(__dirname, "data")
  );

  webApplication.set("url", "https://kill-the-newsletter.com");
  webApplication.set("email", "smtp://kill-the-newsletter.com");
  webApplication.set("administrator", "mailto:kill-the-newsletter@leafac.com");

webApplication.listen(80);

  emailApplication.listen(25, () => {
    console.log("Email server started");
  });
};

I'm deploying with Docker Compose, so my Proxy configuration looks like this (docker-compose.yml):

version: '3'

services:
  # kill the newsletter
  kill-the-newsletter:
    image: kill-the-newsletter
    build: ./ktn-image
    [...]
    environment:
      - VIRTUAL_HOST=domain.com
      - LETSENCRYPT_HOST=domain.com
      - LETSENCRYPT_EMAIL=your@email.com

  # proxy
  proxy:
    build: ./proxy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    volumes:
      - ./data/proxy/certs:/etc/nginx/certs:ro
      - ./data/proxy/vhost.d:/etc/nginx/vhost.d
      - ./data/proxy/html:/usr/share/nginx/html
      - ./data/proxy/acme.sh:/etc/acme.sh
      - /var/run/docker.sock:/tmp/docker.sock:ro
    logging:
      options:
        max-size: "3m"
        max-file: "3"
    networks:
      - proxy-tier

  letsencrypt-companion:
    image: jrcs/letsencrypt-nginx-proxy-companion
    restart: always
    volumes:
      - ./data/proxy/certs:/etc/nginx/certs
      - ./data/proxy/vhost.d:/etc/nginx/vhost.d
      - ./data/proxy/html:/usr/share/nginx/html
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - proxy-tier
    depends_on:
      - proxy

networks:
  proxy-tier:

As I said, I don't have the Dockerfile for the build anymore, but that wasn't really complicated.