Point 2nd subdomain to proxy

Hi I am looking for some help on pointing my 2nd domain to a specific proxy

Here is what I have below but it returns Parse error : Unknown directive “2ndsubdomain.my-site.com

"1stsubdomain.my-site.com {

ext .html .htm .php
root C:\Caddy\www                    

gzip {
    min_length  256
    level       5
}

    # The new code below will startup the server & proxy PHP requests

startup C:\PHP\php-cgi -b 127.0.0.1:9000 &
fastcgi / 127.0.0.1:9000 php {
    index index.php
	
}

    # You can normally use "127.0.0.1" or "localhost", use "Host IP" if your running the web server on different machine

	proxy /abcdef http://10.0.0.50:5369/ {           				
    transparent
}

    proxy /web http://10.0.0.50:32400/ {           				
    transparent
}

	    proxy /abcde http://127.0.0.1:1234 {         			
    transparent
}

		proxy /abcd http://127.0.0.1:1234 {         		
    transparent	
}

	    proxy /radarr http://127.0.0.1:1234 {          	
    transparent
}

	    proxy /stats/ http://10.0.0.50:7890/ {          	
    transparent
}

	    proxy /abc http://127.0.0.1:1234 {           		
    transparent
}

2ndsubdomain.my-site.com {

		proxy /MFR http://127.0.0.1:1234  {
    proxy_header Host {host}
}

No worries - Caddy thinks the format of your Caddyfile is for a single-vhost setup. If you have multiple virtual hosts, each host’s directives must be enclosed in a curly brace block. Like so:

foo.example.com {
    root C:\Caddy\www
    gzip
    ...
}
bar.example.com {
    proxy /mfr http://127.0.0.1:1234 {
        transparent
    }
}

There’s a similar example and more info over at the documentation for the Caddyfile.

Thanks so much I just wasn’t seeing it ! once again great help thank you

Is there any possible way to mask my domain using caddyserver ? I know cloudflare do not offer this i.e.

my-site.com/index /help etc to be shown as my-site.com? @Whitestrake Thanks for all your help so far true hero

I think rewrite has this behaviour, if you’re looking to do this for a single resource. It’s got some quirks, though, be sure to check the docs: https://caddyserver.com/docs/rewrite

my-site.com {
    root /var/www/html
    rewrite / /help
}

If you’re looking to do this site-wide, you’re almost certainly better off writing your website or web app to do this. Most web apps that achieve that kind of effect do it by only actually having one page, and streaming in resources.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.