caddy 2.0 setup reverse proxy

use caddy 2.0 reverse proxy website

Use caddy 2.0 to build a reverse proxy for Disqus API. The URL of the API is:https://disqus.com/api/。

  1. setup reverse_proxy

    1
    2
    3
    
    reverse_proxy https://disqus.com { 
      header_up Host {upstream_hostport}
     }
    
  2. setup rewrite

    1
    
    rewrite * /api{path}
    

    This step is because it needs to be forwarded to the api path。

  3. setup disqus
    websit:https://disqus.com/api/applications/***. Add the domain name of the reverse proxy server to Domains

  4. Verify reverse proxy
    Verify whether the proxy setting is successful. You can access the proxy through a browser and check whether it will jump to this URL https://disqus.com/api/docs/

  5. Complete example

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    www.example.com, 
    :666 {
      tls ***@*mail.com
      rewrite * /api{path}
      reverse_proxy https://disqus.com {
        header_up Host {upstream_hostport}
    #    header_up User-Custom-Domain {host}
    #    header_down Access-Control-Allow-Origin  https://www.example.com
    #    header_down Access-Control-Allow-Credentials=true
    #    health_timeout 5s
    #    transport http {
    #      tls
    #    }
      }
    #  log {
    #    output file /var/log/caddy/access.log
    #  }
    }
    
Licensed under CC BY-NC-SA 4.0