yusing / go-proxy

Easy to use reverse proxy with docker integration
MIT License
99 stars 4 forks source link

go-proxy starts but does not work #4

Closed earvingad closed 5 months ago

earvingad commented 5 months ago

Hello, the program seems to start but it does not work.

Config file content:

providers:
  eee:
    kind: file
    value: eee.yml

Provider eee.yml:

eee: # matching `app1.y.z` -> http://x.y.z
  host: eee.service.lan
  port: 8000

when running sudo /bin/go-proxy I get the following log:

WARN[03-27 21:09:26] invalid autocert config
- no domains specified
- no provider specified
- no email specified
- unknown provider:  component=autocert
INFO[03-27 21:09:26] starting http proxy server on :80
INFO[03-27 21:09:26] starting http panel server on :8080
INFO[03-27 21:09:26] loaded 1 proxy configurations                 component=provider kind=file name=eee

but when I try to enter eee.service.lan I get "enable to connect" and I cannot access 10.0.1.240:8080. Local DNS is correctly pointing eee.service.lan to 10.0.1.240.

I don't know what I am missing.

yusing commented 5 months ago

Hi, thanks for trying go-proxy out. A few questions I want to ask:

yusing commented 5 months ago

I'm sure both your config and eee.yml is valid, seems like it's a connection problem between your machines

earvingad commented 5 months ago

Hi, thanks for trying go-proxy out. A few questions I want to ask:

* What is the IP address of the machine you run `go-proxy`? Is it really `10.0.1.240`?

* Can your client machine (which u tried to access `eee.service.lan`) ping `10.0.1.240`?

* Why do you set `host:` to `eee.service.lan` you want to proxy to port 8000 of the same machine?

Additionally, where should I set the domain "service.lan" so the subdomain like eee.service.lan resolves correctly of I use host: 10.0.1.240 in the eee.yml? Documentation is not clear.

I cannot Access 10.0.1.240:8080 or 127.0.0.1:8080 on the same machine running go-proxy.

yusing commented 5 months ago

I have tried to replicate your config and provider file on a new LXC container, and I found a bug it mistakenly redirected to https even if no cert loaded. But it is not your case, mine showing <a href="https://localhost/?">Moved Permanently</a>.

I cannot Access 10.0.1.240:8080 or 127.0.0.1:8080 on the same machine running go-proxy.

What is the output of curl 127.0.0.1:8080?

earvingad commented 5 months ago

I have tried to replicate your config and provider file on a new LXC container, and I found a bug it mistakenly redirected to https even if no cert loaded. But it is not your case, mine showing <a href="https://localhost/?">Moved Permanently</a>.

I cannot Access 10.0.1.240:8080 or 127.0.0.1:8080 on the same machine running go-proxy.

What is the output of curl 127.0.0.1:8080?

Yes! That same results I get when I use curl. Webbrowser will just error the connection.

yusing commented 5 months ago

Yes! That same results I get when I use curl. Webbrowser will just error the connection.

So I want to get the exact output of curl, to figure out what error is.

I submitted a commit to fix incorrect http -> https redirect when no cert is provided, please run git pull and try again to see if it work now.

yusing commented 5 months ago

image

yusing commented 5 months ago

Additionally, where should I set the domain "service.lan" so the subdomain like eee.service.lan resolves correctly of I use host: 10.0.1.240 in the eee.yml? Documentation is not clear.

As the README shows, domain name does not matter. As long as the DNS resolve eee.service.lan or *.service.lan into 10.0.1.240, you can access all of them.

A simple way to do this, is to set the A record of *.service.lan in your DNS to 10.0.1.240. Then all subdomain to service.lan will resolve to 10.0.1.240. For example:

image

earvingad commented 5 months ago

Thanks for the help, it is working correctly now! Curl before fix:

curl localhost:8080                                      

<a href="https://localhost:8080/?">Moved Permanently</a>.

After fix it is correctly working:

curl localhost:8080       

!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="style.css" rel="stylesheet" />
    <title>go-proxy</title>
  </head>
  <body>
    <script src="main.js"></script>
    <div id="sidenav" class="sidenav">
      <a href="javascript:void(0)" class="closebtn" onclick="closeNav()"
        >&times;</a
      >
      ....

Thanks a lot!