vectorfrog

vectorfrog

I have a number of domain names that all are going to be lead generation sites with just a landing page and lead capture form. So I’d like to host them all as a single app.

I saw this thread which tells me how to set up the application:
https://forum.elixirforum.com/t/multiple-domains-on-a-single-phoenix-app/32528/5

However, I’m trying to test this solution out locally, and so I’ve used the etc/hosts file to point some domains back to “127.0.0.1”. When I ping the domains, I see that they are indeed hitting up 127.0.0.1. However, my phoenix app only works when I visit “localhost” (I’ve changed the port to execute on port 80). If I pull up “127.0.0.1” in a browser, I get a refused to connect message.

Here’s where things get weird. I can sometimes see that when I go to “dummydomain.com” that I’ve redirected to my machine on the 127.0.0.1 IP, and phoenix will throw a message stating that Plug.SSL is redirecting GET / to https://dummydomain.com with a 301 redirect . However, the application doesn’t load in the browser and I just get the refused to connect message in the browser. But when I open “localhost” everything runs as expected.

I’m guessing I’m just missing a configuration option somewhere, but I can’t figure out what it could be. Any ideas?

Showing Posts 1 to 3

derpycoder

derpycoder

I use etc hosts locally as well, using hostsfile tool, so I can have dev and prod parity:

brew install kevinburke/safe/hostsfile
sudo hostsfile add
        derpycoder.site
        s3.derpycoder.site
        www.derpycoder.site
        img.derpycoder.site
        docs.derpycoder.site
        minio.derpycoder.site
        pgweb.derpycoder.site
        search.derpycoder.site
        netdata.derpycoder.site
        livebook.derpycoder.site
        cockroach.derpycoder.site
        127.0.0.1

And then I use a Reverse Proxy, i.e. Caddy to route those to respective ports:

www.derpycoder.site {
	redir https://derpycoder.site permanent
}

derpycoder.site {
	tls certs/caddy/cert.pem certs/caddy/key.pem
	encode zstd gzip

	reverse_proxy localhost:4000 {
		header_up Host {host}
		header_up Origin {host}
		header_up X-Real-IP {remote}
		header_up X-Forwarded-Host {host}
		header_up X-Forwarded-Server {host}
		header_up X-Forwarded-Port {port}
		header_up X-Forwarded-For {remote}
		header_up X-Forwarded-Proto {scheme}
		header_down Access-Control-Allow-Origin https://derpycoder.site
		header_down Access-Control-Allow-Credentials true
	}
}

s3.derpycoder.site {
	reverse_proxy localhost:9000 {
		transport http {
			tls
		}
	}
}

img.derpycoder.site {
	reverse_proxy localhost:3000
}

docs.derpycoder.site {
	encode zstd gzip

	root * doc
	file_server browse
}

minio.derpycoder.site {
	encode zstd gzip

	reverse_proxy localhost:9443 {
		transport http {
			tls
		}
	}
}

pgweb.derpycoder.site {
	encode zstd gzip

	reverse_proxy localhost:8000
}

search.derpycoder.site {
	encode zstd gzip

	reverse_proxy localhost:7700 {
		transport http {
			tls
		}
	}
	# TODO: 7443 as TLS is enabled.
}

netdata.derpycoder.site {
	encode zstd gzip

	reverse_proxy localhost:19999
	# TODO: 19443 when TLS is enabled
}

livebook.derpycoder.site {
	encode zstd gzip

	reverse_proxy localhost:49223
}

cockroach.derpycoder.site {
	encode zstd gzip

	reverse_proxy localhost:8080 {
		transport http {
			tls
		}
	}
	# TODO: 8443 as TLS is enabled.
}
hauleth

hauleth

Probably your application is listening on IPv6 for some reason, so you need to visit [::1] instead.

vectorfrog

vectorfrog OP

Thanks @derpycoder, setting up a reverse proxy was the missing link. I also deep dived into caddy, which is a pretty cool tool.

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews