thedevs-network / kutt

Free Modern URL Shortener.
https://kutt.it
MIT License
8.36k stars 1.08k forks source link

Can't reach the website, getting infinite loop redirecting #645

Open Meow-Bots opened 1 year ago

Meow-Bots commented 1 year ago

Hi, i have Kutt installed with docker-compose, I also use Nginx, but when I try to access the website, i got an error says.

The page isn’t redirecting properly An error occurred during a connection to xyz.com. This problem can sometimes be caused by disabling or refusing to accept cookies.

Here is the .docker.env, docker-compose.yml, and nginx conf files, wonder if anyone can help me figure out what causes the problem.

.docker.env

# App port to run on
PORT=3000

# The name of the site where Kutt is hosted
SITE_NAME=Shorty

# The domain that this website is on
DEFAULT_DOMAIN=xyz.com

# Generated link length
LINK_LENGTH=6

# Postgres database credential details
DB_HOST=postgres
DB_PORT=5432
DB_NAME=kutt
DB_USER=kutt
DB_PASSWORD=dbpassword
DB_SSL=false

# ONLY NEEDED FOR MIGRATION !!1!
# Neo4j database credential details
NEO4J_DB_URI=bolt://localhost
NEO4J_DB_USERNAME=neo4j
NEO4J_DB_PASSWORD=

# Redis host and port
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=

# Disable registration
DISALLOW_REGISTRATION=false

# Disable anonymous link creation
DISALLOW_ANONYMOUS_LINKS=true

# The daily limit for each user
USER_LIMIT_PER_DAY=500

# Create a cooldown for non-logged in users in minutes
# Set 0 to disable
NON_USER_COOLDOWN=0

# Max number of visits for each link to have detailed stats
DEFAULT_MAX_STATS_PER_LINK=5000

# Use HTTPS for links with custom domain
CUSTOM_DOMAIN_USE_HTTPS=false

# A passphrase to encrypt JWT. Use a long and secure key.
JWT_SECRET=jwtpassword

# Admin emails so they can access admin actions on settings page
# Comma seperated
ADMIN_EMAILS=my@email.com

# Invisible reCaptcha secret key
# Create one in https://www.google.com/recaptcha/intro/
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=

# Google Cloud API to prevent from users from submitting malware URLs.
# Get it from https://developers.google.com/safe-browsing/v4/get-started
GOOGLE_SAFE_BROWSING_KEY=

# Google Analytics tracking ID for universal analytics.
# Example: UA-XXXX-XX
GOOGLE_ANALYTICS=
GOOGLE_ANALYTICS_UNIVERSAL=

# Google Analytics tracking ID for universal analytics
# This one is used for links
# GOOGLE_ANALYTICS_UNIVERSAL=

# Your email host details to use to send verification emails.
# More info on http://nodemailer.com/
# Mail from example "Kutt <support@kutt.it>". Leave empty to use MAIL_USER
MAIL_HOST=mail.host.com
MAIL_PORT=465
MAIL_SECURE=true
MAIL_USER=email user
MAIL_FROM=my2@email.com
MAIL_PASSWORD=emilpassword

# The email address that will receive submitted reports.
REPORT_EMAIL=my3@email.com

# Support email to show on the app
CONTACT_EMAIL=my4@email.com

docker-compose.yml

version: "3"

services:
  kutt:
    image: kutt/kutt
    depends_on:
      - postgres
      - redis
    command: ["./wait-for-it.sh", "postgres:5432", "--", "npm", "start"]
    ports:
      - "3369:3000"
    env_file:
      - .docker.env
    environment:
      DB_HOST: postgres
      DB_NAME: kutt
      DB_USER: kutt
      DB_PASSWORD: dbpassword
      REDIS_HOST: redis

  redis:
    image: redis:6.0-alpine
    volumes:
      - redis_data:/data

  postgres:
    image: postgres:12-alpine
    environment:
      POSTGRES_USER: kutt
      POSTGRES_PASSWORD: dbpassword
      POSTGRES_DB: kutt
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  redis_data:
  postgres_data:

kutt.conf

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name xyz.com;

    ssl_certificate /etc/nginx/ssl/cloudflare.crt;
    ssl_certificate_key /etc/nginx/ssl/cloudflare.key;

    location / {
        proxy_pass http://docker0:3369;
  }
}

Docker Container Logs

wait-for-it.sh: waiting 15 seconds for postgres:5432

wait-for-it.sh: postgres:5432 is available after 0 seconds

> kutt@2.7.4 start /usr/src/app

> npm run migrate && cross-env NODE_ENV=production node production-server/server.js

> kutt@2.7.4 migrate /usr/src/app

> knex migrate:latest --env production

Requiring external module ts-node/register

Using environment: production

Already up to date

> Ready on http://localhost:3000
PostgreSQL Database directory appears to contain a database; Skipping initialization

2022-10-16 18:57:27.341 UTC [1] LOG:  starting PostgreSQL 12.12 on x86_64-pc-linux-musl, compiled by gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219, 64-bit

2022-10-16 18:57:27.341 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432

2022-10-16 18:57:27.341 UTC [1] LOG:  listening on IPv6 address "::", port 5432

2022-10-16 18:57:27.342 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

2022-10-16 18:57:27.363 UTC [21] LOG:  database system was interrupted; last known up at 2022-10-14 17:20:36 UTC

2022-10-16 18:57:27.528 UTC [21] LOG:  database system was not properly shut down; automatic recovery in progress

2022-10-16 18:57:27.532 UTC [21] LOG:  redo starts at 0/16E33C0

2022-10-16 18:57:27.532 UTC [21] LOG:  invalid record length at 0/16E34A8: wanted 24, got 0

2022-10-16 18:57:27.532 UTC [21] LOG:  redo done at 0/16E3470

2022-10-16 18:57:27.545 UTC [1] LOG:  database system is ready to accept connections
1:C 16 Oct 2022 18:57:27.133 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

1:C 16 Oct 2022 18:57:27.133 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=1, just started

1:C 16 Oct 2022 18:57:27.133 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf

1:M 16 Oct 2022 18:57:27.137 * Running mode=standalone, port=6379.

1:M 16 Oct 2022 18:57:27.138 # Server initialized

1:M 16 Oct 2022 18:57:27.138 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

1:M 16 Oct 2022 18:57:27.141 * Loading RDB produced by version 6.0.16

1:M 16 Oct 2022 18:57:27.141 * RDB age 164507 seconds

1:M 16 Oct 2022 18:57:27.141 * RDB memory usage when created 0.85 Mb

1:M 16 Oct 2022 18:57:27.141 * DB loaded from disk: 0.002 seconds

1:M 16 Oct 2022 18:57:27.141 * Ready to accept connections

1:M 16 Oct 2022 19:57:28.034 * 1 changes in 3600 seconds. Saving...

1:M 16 Oct 2022 19:57:28.035 * Background saving started by pid 14

14:C 16 Oct 2022 19:57:28.037 * DB saved on disk

14:C 16 Oct 2022 19:57:28.038 * RDB: 0 MB of memory used by copy-on-write

1:M 16 Oct 2022 19:57:28.135 * Background saving terminated with success

1:M 16 Oct 2022 20:57:29.066 * 1 changes in 3600 seconds. Saving...

1:M 16 Oct 2022 20:57:29.066 * Background saving started by pid 15

15:C 16 Oct 2022 20:57:29.068 * DB saved on disk

15:C 16 Oct 2022 20:57:29.068 * RDB: 0 MB of memory used by copy-on-write

1:M 16 Oct 2022 20:57:29.167 * Background saving terminated with success
janoschp commented 1 year ago

Same here.

nocturn9x commented 1 year ago

If anyone is still looking for the solution, setting the domain to localhost:3000 fixed my problem. Such a stupid fix for a stupid problem :P