feat: soportar proxy reverso dinamico y actualizar puerto 2006 de produccion

This commit is contained in:
2026-10-14 07:54:29 -05:00
parent d450d51c98
commit 5f11216cbf
3 changed files with 25 additions and 7 deletions
+1 -1
View File
@@ -1342,7 +1342,7 @@ Aplicación web en Go para transferencia inmediata de archivos, fotos, documento
| Ubicación local | `siax-amd` — `/home/pablinux/Projects/GO/app_compartir` |
| Servidor de producción | `server-webapps` CT 132 (`192.168.10.160`) — pendiente deploy |
| Dominio público | `drop.sigmac.app` |
| Puerto | `8085` |
| Puerto | `2006` |
| Servicio systemd | `app-compartir.service` |
**Bases de Datos:**
+1 -1
View File
@@ -74,7 +74,7 @@ Goroutine periódica (ticker) que consulta items donde `is_guest = true AND expi
| Parámetro | Valor |
|---|---|
| Dominio público | `drop.sigmac.app` |
| Puerto interno | `8085` (o configurable vía `PORT`) |
| Puerto interno | `2006` (producción) / `8085` (local) |
| Servicio systemd | `app-compartir.service` |
| BD principal | SQLite local (`data/compartir.db`) |
| MCP ecosistema | `mcp.telcotronics.net` 🔧 en mantenimiento |
+23 -5
View File
@@ -70,6 +70,21 @@ type PageData struct {
Error string
}
func (h *Handlers) getBaseURL(r *http.Request) string {
proto := "http"
if r.TLS != nil || r.Header.Get("X-Forwarded-Proto") == "https" {
proto = "https"
}
host := r.Host
if host == "" {
host = r.Header.Get("X-Forwarded-Host")
}
if host != "" {
return fmt.Sprintf("%s://%s", proto, host)
}
return h.cfg.BaseURL
}
func (h *Handlers) Index(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
@@ -164,14 +179,15 @@ func (h *Handlers) Upload(w http.ResponseWriter, r *http.Request) {
return
}
baseURL := h.getBaseURL(r)
resp := map[string]interface{}{
"id": share.ID,
"title": share.Title,
"file_size": share.FileSize,
"mime_type": share.MimeType,
"is_guest": share.IsGuest,
"viewer_url": fmt.Sprintf("%s/v/%s", h.cfg.BaseURL, share.ID),
"download_url": fmt.Sprintf("%s/d/%s", h.cfg.BaseURL, share.ID),
"viewer_url": fmt.Sprintf("%s/v/%s", baseURL, share.ID),
"download_url": fmt.Sprintf("%s/d/%s", baseURL, share.ID),
}
if share.IsGuest {
resp["expires_in"] = "24 horas"
@@ -258,14 +274,15 @@ func (h *Handlers) ShareText(w http.ResponseWriter, r *http.Request) {
return
}
baseURL := h.getBaseURL(r)
resp := map[string]interface{}{
"id": share.ID,
"title": share.Title,
"file_size": share.FileSize,
"mime_type": share.MimeType,
"is_guest": share.IsGuest,
"viewer_url": fmt.Sprintf("%s/v/%s", h.cfg.BaseURL, share.ID),
"download_url": fmt.Sprintf("%s/d/%s", h.cfg.BaseURL, share.ID),
"viewer_url": fmt.Sprintf("%s/v/%s", baseURL, share.ID),
"download_url": fmt.Sprintf("%s/d/%s", baseURL, share.ID),
}
if share.IsGuest {
resp["expires_in"] = "24 horas"
@@ -407,7 +424,8 @@ func (h *Handlers) QR(w http.ResponseWriter, r *http.Request) {
return
}
targetURL := fmt.Sprintf("%s/v/%s", h.cfg.BaseURL, id)
baseURL := h.getBaseURL(r)
targetURL := fmt.Sprintf("%s/v/%s", baseURL, id)
pngBytes, err := qrcode.Encode(targetURL, qrcode.Medium, 256)
if err != nil {
http.Error(w, "Error generando QR", http.StatusInternalServerError)