用docker根据proj的docker-compose进行自己搭建API服务器,出现登陆失效问题 #123

Closed
opened 2026-02-21 17:26:04 -05:00 by yindo · 1 comment
Owner

Originally created by @AtmosphereMao on GitHub (May 30, 2023).

image

version: '3.1'
services:
  # API service
  api:
    image: python:3.11.3
    restart: always
    depends_on:
      - db
      - redis
      - weaviate
    volumes:
      # Mount the storage directory to the container, for storing user files.
      - /home/anlly/app/gpt-api:/app/api
    working_dir: /app/api
    ports:
      - "5001:5001"

  # The postgres database.
  db:
    image: postgres:15-alpine
    restart: always
    environment:
      # The password for the default postgres user.
      POSTGRES_PASSWORD: difyai123456
      # The name of the default postgres database.
      POSTGRES_DB: dify
      # postgres data directory
      PGDATA: /var/lib/postgresql/data/pgdata
#    volumes:
#      - ./volumes/db/data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  # The redis cache.
  redis:
    image: redis:6-alpine
    restart: always
    volumes:
      # Mount the redis data directory to the container.
      - ./volumes/redis/data:/data
    # Set the redis password when startup redis server.
    command: redis-server --requirepass difyai123456
    ports:
      - "6380:6379"

#  # The Weaviate vector store.
  weaviate:
    image: semitechnologies/weaviate:1.18.4
    restart: always
    volumes:
      # Mount the Weaviate data directory to the container.
      - ./volumes/weaviate:/var/lib/weaviate
    environment:
      # The Weaviate configurations
      # You can refer to the [Weaviate](https://weaviate.io/developers/weaviate/config-refs/env-vars) documentation for more information.
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      DEFAULT_VECTORIZER_MODULE: 'none'
      CLUSTER_HOSTNAME: 'node1'
      AUTHENTICATION_APIKEY_ENABLED: 'true'
      AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih'
      AUTHENTICATION_APIKEY_USERS: 'hello@dify.ai'
      AUTHORIZATION_ADMINLIST_ENABLED: 'true'
      AUTHORIZATION_ADMINLIST_USERS: 'hello@dify.ai'
    ports:
      - "8080:8080"

docker-compose.yaml如上

# Server Edition
EDITION=SELF_HOSTED

# Your App secret key will be used for securely signing the session cookie
# Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`.
# Alternatively you can set it with `SECRET_KEY` environment variable.
SECRET_KEY=M/ZukbAsbIkOo+1ccn3R67EhYzC4UGs1oPhDtVJ97bUykzDly0l8XBEu

# Console API base URL
CONSOLE_URL=http://192.168.31.83:5001

# Service API base URL
API_URL=http://192.168.31.83:5001

# Web APP base URL
APP_URL=http://192.168.31.83:3001

# celery configuration
CELERY_BROKER_URL=redis://:difyai123456@192.168.31.83:6380/1

# redis configuration
REDIS_HOST=192.168.31.83
REDIS_PORT=6380
REDIS_PASSWORD=difyai123456
REDIS_DB=0

# PostgreSQL database configuration
DB_USERNAME=postgres
DB_PASSWORD=difyai123456
DB_HOST=db
DB_PORT=5432
DB_DATABASE=dify

# Storage configuration
# use for store upload files, private keys...
# storage type: local, s3
STORAGE_TYPE=local
STORAGE_LOCAL_PATH=storage
S3_ENDPOINT=https://your-bucket-name.storage.s3.clooudflare.com
S3_BUCKET_NAME=your-bucket-name
S3_ACCESS_KEY=your-access-key
S3_SECRET_KEY=your-secret-key
S3_REGION=your-region

# CORS configuration
# WEB_API_CORS_ALLOW_ORIGINS=http://192.168.31.83:3001,*
WEB_API_CORS_ALLOW_ORIGINS=*
# CONSOLE_CORS_ALLOW_ORIGINS=http://192.168.31.83:3001,*
CONSOLE_CORS_ALLOW_ORIGINS=*

# Cookie configuration
COOKIE_HTTPONLY=true
COOKIE_SAMESITE=None
COOKIE_SECURE=true

# Session configuration
SESSION_PERMANENT=true
SESSION_USE_SIGNER=true

## support redis, sqlalchemy
SESSION_TYPE=redis

# session redis configuration
SESSION_REDIS_HOST=192.168.31.83
SESSION_REDIS_PORT=6380
SESSION_REDIS_PASSWORD=difyai123456
SESSION_REDIS_DB=2

# Vector database configuration, support: weaviate, qdrant
VECTOR_STORE=weaviate

# Weaviate configuration
WEAVIATE_ENDPOINT=http://192.168.31.83:8080
WEAVIATE_API_KEY=WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
WEAVIATE_GRPC_ENABLED=false

# Qdrant configuration, use `path:` prefix for local mode or `https://your-qdrant-cluster-url.qdrant.io` for remote mode
QDRANT_URL=path:storage/qdrant
QDRANT_API_KEY=your-qdrant-api-key

# Sentry configuration
SENTRY_DSN=

# DEBUG
DEBUG=true
SQLALCHEMY_ECHO=false

api的env文件如上

image

image

目前,登录是正常进行的,但登陆成功后身份凭证并没有保留,显示未登录。

Originally created by @AtmosphereMao on GitHub (May 30, 2023). ![image](https://github.com/langgenius/dify/assets/36625222/f70b717a-4a54-44c7-ad14-8a83e4cb9e68) ``` version: '3.1' services: # API service api: image: python:3.11.3 restart: always depends_on: - db - redis - weaviate volumes: # Mount the storage directory to the container, for storing user files. - /home/anlly/app/gpt-api:/app/api working_dir: /app/api ports: - "5001:5001" # The postgres database. db: image: postgres:15-alpine restart: always environment: # The password for the default postgres user. POSTGRES_PASSWORD: difyai123456 # The name of the default postgres database. POSTGRES_DB: dify # postgres data directory PGDATA: /var/lib/postgresql/data/pgdata # volumes: # - ./volumes/db/data:/var/lib/postgresql/data ports: - "5432:5432" # The redis cache. redis: image: redis:6-alpine restart: always volumes: # Mount the redis data directory to the container. - ./volumes/redis/data:/data # Set the redis password when startup redis server. command: redis-server --requirepass difyai123456 ports: - "6380:6379" # # The Weaviate vector store. weaviate: image: semitechnologies/weaviate:1.18.4 restart: always volumes: # Mount the Weaviate data directory to the container. - ./volumes/weaviate:/var/lib/weaviate environment: # The Weaviate configurations # You can refer to the [Weaviate](https://weaviate.io/developers/weaviate/config-refs/env-vars) documentation for more information. QUERY_DEFAULTS_LIMIT: 25 AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false' PERSISTENCE_DATA_PATH: '/var/lib/weaviate' DEFAULT_VECTORIZER_MODULE: 'none' CLUSTER_HOSTNAME: 'node1' AUTHENTICATION_APIKEY_ENABLED: 'true' AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih' AUTHENTICATION_APIKEY_USERS: 'hello@dify.ai' AUTHORIZATION_ADMINLIST_ENABLED: 'true' AUTHORIZATION_ADMINLIST_USERS: 'hello@dify.ai' ports: - "8080:8080" ``` docker-compose.yaml如上 ``` # Server Edition EDITION=SELF_HOSTED # Your App secret key will be used for securely signing the session cookie # Make sure you are changing this key for your deployment with a strong key. # You can generate a strong key using `openssl rand -base64 42`. # Alternatively you can set it with `SECRET_KEY` environment variable. SECRET_KEY=M/ZukbAsbIkOo+1ccn3R67EhYzC4UGs1oPhDtVJ97bUykzDly0l8XBEu # Console API base URL CONSOLE_URL=http://192.168.31.83:5001 # Service API base URL API_URL=http://192.168.31.83:5001 # Web APP base URL APP_URL=http://192.168.31.83:3001 # celery configuration CELERY_BROKER_URL=redis://:difyai123456@192.168.31.83:6380/1 # redis configuration REDIS_HOST=192.168.31.83 REDIS_PORT=6380 REDIS_PASSWORD=difyai123456 REDIS_DB=0 # PostgreSQL database configuration DB_USERNAME=postgres DB_PASSWORD=difyai123456 DB_HOST=db DB_PORT=5432 DB_DATABASE=dify # Storage configuration # use for store upload files, private keys... # storage type: local, s3 STORAGE_TYPE=local STORAGE_LOCAL_PATH=storage S3_ENDPOINT=https://your-bucket-name.storage.s3.clooudflare.com S3_BUCKET_NAME=your-bucket-name S3_ACCESS_KEY=your-access-key S3_SECRET_KEY=your-secret-key S3_REGION=your-region # CORS configuration # WEB_API_CORS_ALLOW_ORIGINS=http://192.168.31.83:3001,* WEB_API_CORS_ALLOW_ORIGINS=* # CONSOLE_CORS_ALLOW_ORIGINS=http://192.168.31.83:3001,* CONSOLE_CORS_ALLOW_ORIGINS=* # Cookie configuration COOKIE_HTTPONLY=true COOKIE_SAMESITE=None COOKIE_SECURE=true # Session configuration SESSION_PERMANENT=true SESSION_USE_SIGNER=true ## support redis, sqlalchemy SESSION_TYPE=redis # session redis configuration SESSION_REDIS_HOST=192.168.31.83 SESSION_REDIS_PORT=6380 SESSION_REDIS_PASSWORD=difyai123456 SESSION_REDIS_DB=2 # Vector database configuration, support: weaviate, qdrant VECTOR_STORE=weaviate # Weaviate configuration WEAVIATE_ENDPOINT=http://192.168.31.83:8080 WEAVIATE_API_KEY=WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih WEAVIATE_GRPC_ENABLED=false # Qdrant configuration, use `path:` prefix for local mode or `https://your-qdrant-cluster-url.qdrant.io` for remote mode QDRANT_URL=path:storage/qdrant QDRANT_API_KEY=your-qdrant-api-key # Sentry configuration SENTRY_DSN= # DEBUG DEBUG=true SQLALCHEMY_ECHO=false ``` api的env文件如上 ![image](https://github.com/langgenius/dify/assets/36625222/680dd25c-be58-4fc8-b7e0-c4cbae1f5dd8) ![image](https://github.com/langgenius/dify/assets/36625222/1ab4226a-16fc-4d50-a146-1754252f2d88) 目前,登录是正常进行的,但登陆成功后身份凭证并没有保留,显示未登录。
yindo closed this issue 2026-02-21 17:26:04 -05:00
Author
Owner

@AtmosphereMao commented on GitHub (May 30, 2023):

已解决

# COOKIE_SAMESITE=None  改为 Lax
COOKIE_SAMESITE=Lax
@AtmosphereMao commented on GitHub (May 30, 2023): 已解决 ``` # COOKIE_SAMESITE=None 改为 Lax COOKIE_SAMESITE=Lax ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#123