Using two local domains shows single project app in both!

1. The problem I’m having:

I cannot access 2nd app in the second local domain!

2. Error messages and/or full log output:

No error!

3. Caddy version:

v2.10.2

4. How I installed and ran Caddy:

I used brew

a. System environment:

OSX

b. Command:

caddy run --config ./Caddyfile

d. My complete Caddy config:

firstapp.local {
	# Serve your build folder
	root * ./dist
	file_server

	# Enable compression (already working)
	encode gzip zstd

	# Use self-signed certificate for local HTTPS
	tls internal

	# 🚀 CACHE RULES
	# Cache static assets for 1 year
	@static {
		path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.webp *.svg *.woff *.woff2 *.ttf
	}
	header @static Cache-Control "public, max-age=31536000, immutable"

	# Don't cache HTML
	@html {
		path *.html
	}
	header @html Cache-Control "no-cache"

	# Optional: Security headers
	header {
		X-Content-Type-Options "nosniff"
		X-Frame-Options "DENY"
	}
}


secondapp.local {
	reverse_proxy http://localhost:4321
	# Serve your build folder
	root * ./dist
	file_server

	# Enable compression (already working)
	encode gzip zstd

	# Use self-signed certificate for local HTTPS
	tls internal

	# 🚀 CACHE RULES
	# Cache static assets for 1 year
	@static {
		path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.webp *.svg *.woff *.woff2 *.ttf
	}
	header @static Cache-Control "public, max-age=31536000, immutable"

	# Don't cache HTML
	@html {
		path *.html
	}
	header @html Cache-Control "no-cache"

	# Optional: Security headers
	header {
		X-Content-Type-Options "nosniff"
		X-Frame-Options "DENY"
	}
}

FYI: first app is static website and second app is SSR

Take a look at the directive order. It never gets to the reverse_proxy part at all. Also, why your second app has the same configuration as you first app + reverse_proxy? It doesn’t make sense.

1 Like

No need to use file_server with reverse_proxy.

1 Like