mirror of
https://github.com/plausible/analytics.git
synced 2024-11-23 11:12:15 +03:00
Fix configuration for firewall
This commit is contained in:
parent
2e1904e5f0
commit
74b74a271e
@ -182,7 +182,7 @@ config :plausible, :custom_domain_server,
|
||||
ip: System.get_env("CUSTOM_DOMAIN_SERVER_IP")
|
||||
|
||||
config :plausible, PlausibleWeb.Firewall,
|
||||
blocklist: System.get_env("IP_BLOCKLIST", "")
|
||||
blocklist: System.get_env("IP_BLOCKLIST", "") |> String.split(",") |> Enum.map(&String.trim/1)
|
||||
|
||||
config :geolix,
|
||||
databases: [
|
||||
|
@ -148,7 +148,7 @@ config :plausible, :custom_domain_server,
|
||||
ip: custom_domain_server_ip
|
||||
|
||||
config :plausible, PlausibleWeb.Firewall,
|
||||
blocklist: System.get_env("IP_BLOCKLIST", "")
|
||||
blocklist: System.get_env("IP_BLOCKLIST", "") |> String.split(",") |> Enum.map(&String.trim/1)
|
||||
|
||||
base_cron = [
|
||||
# Daily at midnight
|
||||
|
@ -1,16 +1,13 @@
|
||||
defmodule PlausibleWeb.Firewall do
|
||||
import Plug.Conn
|
||||
|
||||
def init(options) do
|
||||
blocklist = Keyword.fetch!(Application.get_env(:plausible, __MODULE__), :blocklist)
|
||||
|> String.split(",")
|
||||
|> Enum.map(&String.trim/1)
|
||||
|
||||
Keyword.merge(options, blocklist: blocklist)
|
||||
def init(opts) do
|
||||
opts
|
||||
end
|
||||
|
||||
def call(conn, opts) do
|
||||
if PlausibleWeb.RemoteIp.get(conn) in opts[:blocklist] do
|
||||
def call(conn, _opts) do
|
||||
blocklist = Keyword.fetch!(Application.get_env(:plausible, __MODULE__), :blocklist)
|
||||
if PlausibleWeb.RemoteIp.get(conn) in blocklist do
|
||||
send_resp(conn, 404, "Not found") |> halt
|
||||
else
|
||||
conn
|
||||
|
Loading…
Reference in New Issue
Block a user