kanishka-linux / reminiscence

Self-Hosted Bookmark And Archive Manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reminiscense as Subdomain with Nginx reverse proxy

vinanrra opened this issue · comments

Hi,

Thanks for this amazing project, but i would like to do a reverse proxy to a subdomain like this:

reminiscense.domian.xx

But i am a not very familiar with reverse proxy could anyone help me to do it or give me some info to do it myself?

Im using this docker container to do all my reverse proxy:

https://hub.docker.com/r/linuxserver/letsencrypt/

With this:

https://github.com/linuxserver/reverse-proxy-confs

And if possible i will pull the config to the repository.

Thanks.

commented

I think it is possible. Just search internet, you'll get the answer. If you want to serve reminiscence under subdirectory then there is this issue which you can refer to.

commented

Hello! Thanks for the amazing project!

I'm facing the same problem. I'm trying to run reminiscence under articles.mydomain.example but can't get it to work.

Here is what I've been tried:

The docker-compose.yml file

version: '3'

services:
  reminiscence:
    build: .
    command: bash -c "while ! nc -w 1 -z db 5432; do sleep 0.1; done; python manage.py migrate; python manage.py createdefaultsu; python manage.py collectstatic --no-input; if [ ! -d '/usr/src/reminiscence/static/nltk_data' ]; then echo 'wait..downloading..nltk_data'; python manage.py nltkdownload; fi; gunicorn --max-requests 1000 --worker-class gthread --workers 4 --thread 10 --timeout 300 --bind 0.0.0.0:8000 reminiscence.wsgi"
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
      VIRTUAL_HOST: ${DOMAIN}
      VIRTUAL_PORT: ${VIRTUAL_PORT}
      LETSENCRYPT_HOST: ${DOMAIN}
      LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
    volumes:
      - ./static:/usr/src/reminiscence/static/
      - ./archive:/usr/src/reminiscence/archive/
      - ./logs:/usr/src/reminiscence/logs/
    depends_on:
      - reminiscence-db

  reminiscence-db:
    image: postgres:11
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
    volumes:
      - ./db:/var/lib/postgresql/data/

networks:
   default:
     external:
       name: ${NETWORK}

The .env file

POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=verystrongpassword
DOMAIN=articles.mydomain.example
VIRTUAL_PORT=8000
LETSENCRYPT_EMAIL=admin@mydomain.example
NETWORK=webproxy

I deleted the nginx service in the original Dockerfile . Instead, I'm using this nginx proxy.

Any help is welcome!

I had quite the adventure with this, and I am pretty sure this is not how you should do things with nginx, but if someone has a better way of doing this, lemme know. So, first things first, make sure that your CNAME record is set on your DNS provider, I had quite the fun time debugging and stupidly forgetting not to set that bugger, and then quickly came to the conclusion. For one, you will not being using the nginx inside to route to your domain, it will be enabled and listening, but for some reason it just doesn't work when you have to point it at say, SSL certificates. I am rather young and inexperienced, so I am not 100% sure why it is failing, maybe after a few blue moons I will be able to tell you. This being said, install nginx on your server and configure it to your liking. I won't tell you how to do this as there is plenty of guides on how to write and configure an nginx.conf, and the default works fine. Here is my own server entry under http:

/etc/nginx/nginx.conf:

server {
                listen 443 ssl;
                server_name bookmarks.example.com;
                ssl_verify_client       on;
                ssl_certificate         /path/to/cert.pem;
                ssl_certificate_key     /path/to//key.pem;
                ssl_client_certificate  /path/to/client.crt;
                location / {
                        proxy_pass      http://localhost;
                }

(Change bookmarks.example.com to your own domain and subdomain, and if you have SSL stuff change that as well)

As you can see, we're taking passing localhost to 443, which is the SSL port. If you wanted to pass it something else, just replace that. I also included my configuration for SSL, but if you wanted an unencrypted entry, it'd be easy as removing all that and setting listen to just 80. I haven't tested this, mind you, as it isn't possible for me to test it with my current configuration. You may be tempted to include say, include /static/, but this will break everything. Obviously, you can configure other things with this reverse proxy, so anything extra you wanted to include in ~/reminiscence/nginx.conf you could possibly add here, I haven't done anything of the like though so can't confirm. I may test this more if time permits and my own interest is strong enough, but assuming that this just works for me I probably won't pursue it any further. Cheers!

commented

Hey, @coletonodonnell , thanks for sharing your little adventure. I'm sure, your tips will be helpful to people facing the issue.