[GH-ISSUE #2982] Feature request: Reverse Proxy with Caddy #1993

Closed
opened 2026-10-31 20:22:28 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Gill-Bates on GitHub (May 7, 2025).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/2982

I want to share my Caddy Config for adding it into the Repo.

This Config works only with Websocket-Configuration!

Image

Image

/etc/caddy/Caddyfile

vpn.example.com {

    encode gzip

    # TLS 1.3 mandatory!
    tls {
        protocols tls1.3
    }

    # Protect your GUI with Basic Auth
    route /admin* {
        basic_auth {
            admin ******
        }
        reverse_proxy xx.xx.xx.xx:2053
    }

    # Obfuscate the Endpoint
    route /api/v1* {
        @websockets {
            header Connection *Upgrade*
            header Upgrade websocket
        }
        reverse_proxy @websockets xx.xx.xx.xx:54321
        respond "Forbidden" 403
    }

    # Security Header
    header {
        header_up Authorization { >Authorization }
        header_up Content-Type { >Content-Type }
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
        X-Content-Type-Options nosniff
        X-Frame-Options SAMEORIGIN
        Referrer-Policy strict-origin-when-cross-origin
        -Server
        -X-Powered-By
    }

    # Fallback
    respond "Not found!" 404
}

Describe the solution you'd like

What is happening here?

  • Requesting vpn.example.com will end up in 404 Not found
  • The GUI-Portal (Basic Auth protected) is available with vpn.example.com/admin
  • The Endpoint is obfuscated with vpn.example.com/api/v1
  • Only Websocket-Connection are allowed. All other requests ends up in 403 Forbidden

Describe alternatives you've considered

No response

Checklist

  • This feature report is written entirely in English.
Originally created by @Gill-Bates on GitHub (May 7, 2025). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/2982 I want to share my Caddy Config for adding it into the Repo. **This Config works only with Websocket-Configuration!** ![Image](https://github.com/user-attachments/assets/b2bde04f-311a-4f71-9fd8-0503c4883464) ![Image](https://github.com/user-attachments/assets/0f00d1cc-c114-4b83-9325-549c0906c30a) `/etc/caddy/Caddyfile` ``` vpn.example.com { encode gzip # TLS 1.3 mandatory! tls { protocols tls1.3 } # Protect your GUI with Basic Auth route /admin* { basic_auth { admin ****** } reverse_proxy xx.xx.xx.xx:2053 } # Obfuscate the Endpoint route /api/v1* { @websockets { header Connection *Upgrade* header Upgrade websocket } reverse_proxy @websockets xx.xx.xx.xx:54321 respond "Forbidden" 403 } # Security Header header { header_up Authorization { >Authorization } header_up Content-Type { >Content-Type } Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" X-Content-Type-Options nosniff X-Frame-Options SAMEORIGIN Referrer-Policy strict-origin-when-cross-origin -Server -X-Powered-By } # Fallback respond "Not found!" 404 } ``` ### Describe the solution you'd like What is happening here? - Requesting `vpn.example.com` will end up in `404 Not found` - The GUI-Portal (Basic Auth protected) is available with `vpn.example.com/admin` - The Endpoint is obfuscated with `vpn.example.com/api/v1` - Only Websocket-Connection are allowed. All other requests ends up in `403 Forbidden` ### Describe alternatives you've considered _No response_ ### Checklist - [x] This feature report is written entirely in English.
bsakaguchi 2026-10-31 20:22:28 +07:00
Author
Owner

@sh1shd commented on GitHub (May 28, 2025):

Hello!

Thank you for your config, it has been added to the wiki.

<!-- gh-comment-id:2915815848 --> @sh1shd commented on GitHub (May 28, 2025): Hello! Thank you for your config, it has been added to the [wiki](https://github.com/MHSanaei/3x-ui/wiki/Configuration#caddy).
Author
Owner

@AYastrebov commented on GitHub (Jun 26, 2025):

Hi, as far as I see, it's not allowed to add header_up in header block

<!-- gh-comment-id:3007517216 --> @AYastrebov commented on GitHub (Jun 26, 2025): Hi, as far as I see, it's not allowed to add `header_up` in `header` block
Author
Owner

@ghost commented on GitHub (Aug 19, 2025):

Hi, as far as I see, it's not allowed to add header_up in header block

what we can do?

<!-- gh-comment-id:3201253485 --> @ghost commented on GitHub (Aug 19, 2025): > Hi, as far as I see, it's not allowed to add `header_up` in `header` block what we can do?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#1993
No description provided.