jaesivsm / JARR

JARR is a web news aggregator.
https://app.jarr.info
GNU Affero General Public License v3.0
117 stars 15 forks source link

install on vps #219

Open KvizadSaderah opened 1 year ago

KvizadSaderah commented 1 year ago

Hello sir!

Can you help me debug, again?

I'm trying to install JARR to VPS to my domain like https://example.com

And i'm using apache to route it, but can't achive result.

Can you help me what is wrong, and how to fix that?

cat prod.yml

version: '3'
services:
  jarr-server:
    build:
      context: ../.
      dockerfile: ./Dockerfiles/server
    ports:
      - "127.0.0.1:8500:8000"
    # You'll a folder with at least jarr.json, logging.ini and gunicorn.py
    volumes:
      - ../example_conf/:/etc/jarr:ro
    depends_on:
      - postgres
      - redis
      - rabbitmq
    networks:
      jarr:
  jarr-front:
    build:
      context: ../.
      dockerfile: ./Dockerfiles/front
      args:
        PUBLIC_URL: http://example.com:8501/
        REACT_APP_API_URL: http://localhost:8500/
    ports:
      - "127.0.0.1:8501:80"
    depends_on:
      - jarr-server
    networks:
      - jarr
  jarr-worker:
    build:
      context: ../.
      dockerfile: ./Dockerfiles/server
    # You'll a folder with at least jarr.json, logging.ini and gunicorn.py
    volumes:
      - ../example_conf/:/etc/jarr:ro
    depends_on:
      - postgres
      - redis
      - rabbitmq
    networks:
      - jarr
  rabbitmq:
    container_name: rabbitmq
    hostname: rabbitmq
    image: rabbitmq
    networks:
      - jarr
  redis:
    container_name: redis
    hostname: redis
    image: redis
    networks:
      - jarr
  postgres:
    container_name: postgres
    hostname: postgres
    image: postgres:13
    ports:
      - 127.0.0.1:5432:5432
    networks:
      - jarr
    # remove that on real prod env and set proper db password
    environment:
      - POSTGRES_PASSWORD=E5XrjanDTeUUiG3P4caPHBnddcgBxYoTdPJ4SMdq7awLn3BBzz 
      - POSTGRES_HOST_AUTH_METHOD=trust
    # Directory in which your db will save its data, change it to some absolute path
    volumes:
      - ../.jarr-data:/var/lib/postgresql/data

networks:
  jarr:

cat example.com.conf

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    ErrorLog /var/log/apache2/example-error.log
    CustomLog /var/log/apache2/example-access.log combined

    # Redirect all HTTP traffic to HTTPS
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

upd: tried to run local on debian VM to (with default settings) to check if it works for me, or i'm doing something wrong from beginning, so it's works localy. But how to tide it to custom domain? that it would work? >_<

jaesivsm commented 1 year ago

First, check that your instance is properly running. On your VPS curl http://localhost:8500/swagger.json should return a json payload.

Then ensure that your configuration file (which should be somewhere like /etc/jarr/jarr.json has api.url defined to https://example.com

Lastly, and I think most importantly, your apache configuration is wrong.

  1. if you're serving on https first line should be <VirtualHost *:443>, 80 being the port of HTTP
  2. if you're serving on https you need to include both SSLCertificateFile and SSLCertificateKeyFile directives with the proper certificate values
  3. in any case you need to provide the proper proxy pass configuration :
    ProxyPass / http://127.0.0.1:8500/
    ProxyPassReverse / http://127.0.0.1:8500/
  4. if you're serving on https you'll also need RequestHeader set X-Forwarded-Proto https

To sum up : the apache file you have there is to redirect http traffic to https. To serve JARR over https you'd need another virtualhost listening on 443. If you can reach JARR locally on you VPS (with curl or wget or whatever) it means JARR is working but you can't reach from the outside. That means you'll need to fix your apache configuration and this will be very dependent on your particular case.

KvizadSaderah commented 1 year ago

okay, i'm lost on step of docker-compose file.

  1. curl http://localhost:8500/swagger.json - returned a json payload. But there was no jarr directory in /etc/, because i didn't change paths.
  2. So i have had a look and there is no api.url
  3. So i've ask chatGPT to have a look and make it as required, so he changed REACT_APP_API_URL to format like http://example.com:8500/ and then it fails on last step make: *** [Makefile:87: init-env-docker] Error 1 or some other errors
  4. so i never reached step with apache settings again
  5. and while i don't know how to uninstall it all (i stopped docker and did docker system prune -a to remove everything, still got errors), so i'm wiping out VPS each fail :E and it's quite long to get back with new checks

Can you please show valid prod.yml for use on VPS ? so i just would replace password and domain to mine ? >_>

p.s. my jarr.json cat jarr.json

{
    "jarr_testing": false,
    "crawler": {
        "login": "admin",
        "passwd": "admin"
    },
    "log": {
        "level": 10
    },
    "db": {
        "pg_uri": "postgresql://jarr@postgres:5432/jarr",
        "redis": {"host": "redis"},
        "metrics": {"host": "redis"}
    },
    "celery": {"broker": "amqp://rabbitmq//",
               "backend": "redis://redis:6379/0",
               "broker_url": "amqp://rabbitmq//"},
    "auth": {"secret_key": "my not so secret key"}
}
KvizadSaderah commented 1 year ago

please help '(°Ω°)/