I've done some digging through the interwebs and haven't been able to come across anything similar (at least near any solution that has worked out for me).
Essentially, I am running a Golang server locally on 127.0.0.1:1337
, I want this to be accessible globally so I use Nginx to forward traffic from https://api.example.com/
to my API to retrieve information.
With that being said, I have simply setup my Golang server to listen and serve on port 1337
and my Nginx configuration is setup to redirect all HTTP traffic (for all domains) to HTTPS:
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
and then I redirect traffic to port 1337 here:
server {
server_name api.example.com;
location / {
proxy_pass http://127.0.0.1:1337;
}
listen 443 ssl;
ssl_certificate_key /etc/nginx/ssl/private.key;
ssl_certificate /etc/nginx/ssl/cert.crt;
}
The issue with this is that I find myself to keep getting redirects from HTTPS to HTTP (as per wget) and I end up getting a Too Many Redirects
error.
If anyone can provide some guidance, I'd very much appreciate it!