Nginx cert proxy setup - sites will not load

We have been using the CDN function from the older Javascript Apps. That seems to be broken now and I can not add a Backend from the web-app (screenshot below)

So I decided to try setting up a Nginx proxy following these instructions.

https://fly.io/docs/app-guides/global-nginx-proxy/#configuring-nginx

And this example dockerfile:

I got docker installed and created the image. It seems to deploy just fine but never redirects me. I tried to setup a simple www.emergingbroker.com to www.listingvillage.com redirect by just modifying the example like so:

user  nginx;
worker_processes 1;
error_log  /dev/stderr info;
pid        /var/run/nginx.pid;

events {
    worker_connections  4096;
    multi_accept        on;
}

http {
	server {
	  listen 8080;
	  listen [::]:8080;

	  server_name emergingbroker.com;

	  location / {
	      proxy_pass https://www.listingvillage.com/;
	      proxy_set_header X-Forwarded-Host $http_host;
	  }
	}

	server {
	  listen 8080;
	  listen [::]:8080;

	  server_name www.emergingbroker.com;

	  location / {
	      proxy_pass https://www.listingvillage.com/;
	      proxy_set_header X-Forwarded-Host $http_host;
	  }
	}
	# health check server
   	server {
        listen 8080;
        server_name health.check;

        location /healthz {
            access_log /dev/stdout;
            return 200 "ok";
        }
    }
}

I could really use some help on this as I need to get three new sites up and running. Also the server will crash if I don’t include server_name health.check from the example, but that is not mentioned in the Nginx guide. It kind of feels I’m trying to fit different pieces of a puzzle together that I don’t understand. It would be nice if there was a working code example to create a cert service like the CDN from the older version of Fly.

-Matt

We do need a better example for nginx for this purpose. I pushed a slightly nicer (and ready to run) example here: GitHub - fly-apps/nginx: A fly app nginx config

If you clone that, then change the lines indicated in the README, you should be in a pretty good spot. For your app in particular, you probably don’t want to point nginx to www.listingvillage.com, it would be better to bypass that and proxy directly to your origin host.

One thing that’s cool with docker is that you can test this locally. Once you have a config that might work, do this:

docker build . -t nginx-proxy
docker run -p 8080:8080 nginx-proxy

Then you can use curl to try it out:

curl -D - -o /dev/null -sS http://localhost:8080 -H "Host: www.emergingbroker.com"

Alright… I’m on version 19 and can’t get the server to do anything. I can’t even reach the IP 213.188.198.0 or the hostname https://product-sites.fly.dev/

I used the files from the linked Git Repository.

I modified the nginx.conf with the origin URL as my live server IP address that is working with the old Fly JavaScript apps 3.82.124.117 and I comment out line 35 and uncomment line 38 to send the host header.

I’m getting this (which comes from the origin) when I try that URL:

image

Give me a sec with this, it looks like you got a .0 IP address for this app. I’m going to switch it to another IP and see if it helps.

Invalid Host Name Request is exactly what I’m looking for! That is a config warning on our end.

But I’m getting (tested on multiple computers / networks):

That’s likely the .0 IP. Give it a few minutes to get the updated on in DNS and see if that helps? That is a wholly unrelated bug, sorry about that.

1 Like

AWESOME!!

I created a new domain name so emergingbroker.com DNS wouldn’t be cached.

joinhomebuyeralerts.com was just setup and seems to be working certs and all!

THANK YOU!

1 Like