klzgrad / naiveproxy

Make a fortune quietly
BSD 3-Clause "New" or "Revised" License
6.6k stars 879 forks source link

use alternative http/https port and add multiple auth accounts #605

Closed monkey-jsun closed 9 months ago

monkey-jsun commented 9 months ago

I followed the readme.md file and got everything up and running. Great! Thanks!

I like to venture to tweak a couple of things, but I'm having troubles.

The first challenge is to use alternative http/https ports(8080/8443). I added the following directives to the Caddyfile and caddy starts up fine with the designated high ports. However, when I open URL at http://:8080, the browser redirects to https://:443, instead of https://:8443. How do I achieve this?

{
        order forward_proxy before file_server
        https_port 8443
        http_port 8080
}
:8443, vpn.my.net {
        tls admin@my.net
        forward_proxy {
                basic_auth user password
                hide_ip
                hide_via
                probe_resistance
        }
        file_server {
                root /var/www/html
        }
}

My second challenge is to add multiple user accounts. How do I do that?

BTW, I googled Caddyfile format and it seems quite different from what is used here. For example, forward_proxy would become forwardproxy, and basic_auth becomes basicauth. I'm quite lost.

5l2 commented 9 months ago

For the first point, you should refer to the official Caddy documentation and inquire in the Caddy community. Regarding the second point, you can refer to other relevant issues, such as https://github.com/klzgrad/naiveproxy/issues/587.

monkey-jsun commented 9 months ago

Thanks for the pointer. Do you know why the official Caddy document looks similar but not exactly the same? For example, in your example we use "basic_auth", but in the official Caddyfile document it uses "basicauth", which supports multiple users.

There are others that also fall into this strange "similar but different" category, such as forward_proxy vs forwardproxy.

5l2 commented 9 months ago

Yes, because Caddy has two versions. To be compatible with Caddy 2, the latest forwardproxy (caddy2 branch) indeed uses the forward_proxy and basic_auth directives, whereas the previous version (master branch) used forwardproxy and basicauth directives.

klzgrad commented 7 months ago

Multiple auth is fixed here https://github.com/klzgrad/forwardproxy/releases/tag/v2.7.6-naive