mirror of
https://github.com/langgenius/dify.git
synced 2026-04-07 08:46:31 +08:00
- Add marketplace.dify.ai to default allowed domains in squid.conf - Remove separate marketplace configuration example as it's no longer needed - Update documentation to reflect marketplace is allowed by default
87 lines
3.7 KiB
Plaintext
87 lines
3.7 KiB
Plaintext
################################## SSRF Protection Configuration ##################################
|
|
# This is a strict default configuration to prevent SSRF attacks
|
|
# To allow additional domains or relax restrictions, create config files in /etc/squid/conf.d/
|
|
|
|
################################## Security ACLs ##################################
|
|
# Define private/local networks that should be BLOCKED by default
|
|
acl private_networks dst 0.0.0.0/8 # "This" network
|
|
acl private_networks dst 10.0.0.0/8 # RFC 1918 private network
|
|
acl private_networks dst 100.64.0.0/10 # RFC 6598 shared address space
|
|
acl private_networks dst 127.0.0.0/8 # Loopback
|
|
acl private_networks dst 169.254.0.0/16 # RFC 3927 link-local
|
|
acl private_networks dst 172.16.0.0/12 # RFC 1918 private network
|
|
acl private_networks dst 192.168.0.0/16 # RFC 1918 private network
|
|
acl private_networks dst 224.0.0.0/4 # Multicast
|
|
acl private_networks dst 240.0.0.0/4 # Reserved for future use
|
|
acl private_networks dst 255.255.255.255/32 # Broadcast
|
|
acl private_networks dst fc00::/7 # IPv6 unique local addresses
|
|
acl private_networks dst fe80::/10 # IPv6 link-local addresses
|
|
acl private_networks dst ::1/128 # IPv6 loopback
|
|
acl private_networks dst ff00::/8 # IPv6 multicast
|
|
|
|
# Define ports
|
|
acl SSL_ports port 443
|
|
acl Safe_ports port 80 # http
|
|
acl Safe_ports port 443 # https
|
|
acl CONNECT method CONNECT
|
|
|
|
################################## Access Control Rules ##################################
|
|
# IMPORTANT: Order matters! First matching rule wins.
|
|
|
|
# Special rule for reverse proxy port (sandbox access)
|
|
# This must come FIRST to bypass other restrictions for sandbox connectivity
|
|
acl reverse_proxy_port myport ${REVERSE_PROXY_PORT}
|
|
http_access allow reverse_proxy_port
|
|
|
|
# Allow access to Dify marketplace (always allowed by default)
|
|
acl allowed_marketplace dstdomain .marketplace.dify.ai
|
|
http_access allow allowed_marketplace
|
|
|
|
# DENY access to all private/local networks - prevents SSRF attacks
|
|
http_access deny private_networks
|
|
|
|
# DENY non-safe ports
|
|
http_access deny !Safe_ports
|
|
|
|
# DENY CONNECT to non-SSL ports
|
|
http_access deny CONNECT !SSL_ports
|
|
|
|
# Allow manager access from localhost only
|
|
http_access allow localhost manager
|
|
http_access deny manager
|
|
|
|
# Allow localhost to access services (needed for integration tests)
|
|
acl localhost src 127.0.0.1/32 ::1
|
|
http_access allow localhost
|
|
|
|
# User overrides in /etc/squid/conf.d/*.conf should be placed here
|
|
include /etc/squid/conf.d/*.conf
|
|
|
|
# Final deny all
|
|
http_access deny all
|
|
|
|
################################## Proxy Server Configuration ##################################
|
|
http_port ${HTTP_PORT}
|
|
coredump_dir ${COREDUMP_DIR}
|
|
|
|
# Refresh patterns
|
|
refresh_pattern ^ftp: 1440 20% 10080
|
|
refresh_pattern ^gopher: 1440 0% 1440
|
|
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
|
|
refresh_pattern \/(Packages|Sources)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
|
|
refresh_pattern \/Release(|\.gpg)$ 0 0% 0 refresh-ims
|
|
refresh_pattern \/InRelease$ 0 0% 0 refresh-ims
|
|
refresh_pattern \/(Translation-.*)(|\.bz2|\.gz|\.xz)$ 0 0% 0 refresh-ims
|
|
refresh_pattern . 0 20% 4320
|
|
|
|
# Upstream proxy configuration (uncomment and configure if needed)
|
|
# cache_peer <upstream_proxy_ip> parent 3128 0 no-query no-digest no-netdb-exchange default
|
|
|
|
################################## Reverse Proxy To Sandbox ##################################
|
|
# This configuration allows the sandbox to be accessed through the reverse proxy
|
|
# The reverse proxy port is separate from the main proxy port and has different rules
|
|
http_port ${REVERSE_PROXY_PORT} accel vhost
|
|
cache_peer ${SANDBOX_HOST} parent ${SANDBOX_PORT} 0 no-query originserver
|
|
|
|
# Buffer size for file uploads
|
|
client_request_buffer_max_size 100 MB |