Fix Dokploy Bad Gateway: dokploy-network and expose 8080.

This commit is contained in:
2026-07-29 09:35:08 +03:00
parent 08750add83
commit 57d8ed7388
5 changed files with 31 additions and 13 deletions
+15 -8
View File
@@ -1,18 +1,25 @@
# Dokploy / Docker Compose env (copy to .env and edit) # App
APP_PORT=8080
APP_URL=https://wg.example.com APP_URL=https://test200.de4ima.uk
SITE_NAME=Evilfox.cc SITE_NAME=Evilfox.cc
SECURE_COOKIES=true SECURE_COOKIES=true
SESSION_SECRET=replace-with-long-random-secret SESSION_SECRET=change-me-to-long-random-string
# Admin (логин админки — только из env)
ADMIN_USERNAME=admin ADMIN_USERNAME=admin
ADMIN_EMAIL=admin@evilfox.cc ADMIN_EMAIL=admin@evilfox.cc
ADMIN_PASSWORD=replace-with-strong-admin-password ADMIN_PASSWORD=change-me-strong-password
# PostgreSQL 17
POSTGRES_DB=wg POSTGRES_DB=wg
POSTGRES_USER=wg POSTGRES_USER=wg
POSTGRES_PASSWORD=replace-with-strong-db-password POSTGRES_PASSWORD=change-me-db-password
# Import old MySQL dump once (wg.sql)
AUTO_IMPORT_MYSQL=true AUTO_IMPORT_MYSQL=true
APP_PUBLISH_PORT=8080 MYSQL_DUMP_PATH=/data/wg.sql
TZ=Europe/Moscow
# Dokploy Domain tab:
# Service = app
# Port = 8080
TZ=UTC
+1 -1
View File
@@ -23,6 +23,6 @@ ENV APP_ROOT=/app \
APP_PORT=8080 APP_PORT=8080
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
CMD curl -fsS http://127.0.0.1:8080/login >/dev/null || exit 1 CMD curl -fsS http://127.0.0.1:8080/healthz >/dev/null || exit 1
USER nobody USER nobody
CMD ["/app/wg-panel"] CMD ["/app/wg-panel"]
+5
View File
@@ -70,6 +70,11 @@ func main() {
fileServer(r, "/static/", http.Dir(staticDir)) fileServer(r, "/static/", http.Dir(staticDir))
r.Get("/", app.Home) r.Get("/", app.Home)
r.Get("/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
})
r.Get("/login", app.LoginPage) r.Get("/login", app.LoginPage)
r.Post("/login", app.LoginPost) r.Post("/login", app.LoginPost)
r.Get("/logout", app.Logout) r.Get("/logout", app.Logout)
+9 -3
View File
@@ -15,6 +15,7 @@ services:
retries: 20 retries: 20
networks: networks:
- wg - wg
- dokploy-network
app: app:
build: . build: .
@@ -22,8 +23,9 @@ services:
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
ports: # Dokploy/Traefik routes to this internal port — do NOT publish host ports.
- "${APP_PUBLISH_PORT:-8080}:8080" expose:
- "8080"
environment: environment:
APP_PORT: "8080" APP_PORT: "8080"
APP_URL: ${APP_URL:-http://localhost:8080} APP_URL: ${APP_URL:-http://localhost:8080}
@@ -35,10 +37,11 @@ services:
ADMIN_PASSWORD: ${ADMIN_PASSWORD:?set ADMIN_PASSWORD} ADMIN_PASSWORD: ${ADMIN_PASSWORD:?set ADMIN_PASSWORD}
AUTO_IMPORT_MYSQL: ${AUTO_IMPORT_MYSQL:-true} AUTO_IMPORT_MYSQL: ${AUTO_IMPORT_MYSQL:-true}
MYSQL_DUMP_PATH: /data/wg.sql MYSQL_DUMP_PATH: /data/wg.sql
SECURE_COOKIES: ${SECURE_COOKIES:-false} SECURE_COOKIES: ${SECURE_COOKIES:-true}
TZ: ${TZ:-UTC} TZ: ${TZ:-UTC}
networks: networks:
- wg - wg
- dokploy-network
volumes: volumes:
pgdata: pgdata:
@@ -46,3 +49,6 @@ volumes:
networks: networks:
wg: wg:
driver: bridge driver: bridge
# Required so Traefik (Dokploy) can reach containers.
dokploy-network:
external: true
+1 -1
View File
@@ -66,7 +66,7 @@ func (a *App) SiteOnline(ctx context.Context) (models.SiteStatus, error) {
func (a *App) OfflineMiddleware(next http.Handler) http.Handler { func (a *App) OfflineMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/login") || strings.HasPrefix(r.URL.Path, "/admin") || strings.HasPrefix(r.URL.Path, "/static") { if strings.HasPrefix(r.URL.Path, "/login") || strings.HasPrefix(r.URL.Path, "/admin") || strings.HasPrefix(r.URL.Path, "/static") || r.URL.Path == "/healthz" {
next.ServeHTTP(w, r) next.ServeHTTP(w, r)
return return
} }