gluetun icon indicating copy to clipboard operation
gluetun copied to clipboard

Change Region of running container

Open calgara12 opened this issue 4 years ago • 14 comments

Hey, is it possible to change the region without stopping the container setting a new environment variable and starting it again?

Could it be done with a script inside the container?

Thanks for this. Cheers

calgara12 avatar Mar 17 '20 21:03 calgara12

It probably could not be changed that easily, it would have to go through the Golang entrypoint program.

I think I'm gonna develop a simple web ui + http server in the existing entrypoint to change settings once it's running, starting with changing region. However that may take me weeks to do. I will comment back once I start developing it.

Another ugly but quicker way would be to access an http route like /update?region=bla&isp=3339 but I'd like to avoid that if possible :smile:

qdm12 avatar Mar 17 '20 23:03 qdm12

Thanks for your quick response. That would be awesome. :)

calgara12 avatar Mar 18 '20 05:03 calgara12

@qdm12 - if at all possible, maybe add a way to select the vpn-provider region in the web controls. would be easier (for us ;) ) than editing the compose file each time and recreating...

lavaguy1 avatar Jun 29 '20 20:06 lavaguy1

Hi a quick update from my side; I'm a bit busy with other projects right now but will do that in the coming 4-12+ weeks, sorry for the wait. What's below is the steps i need to do (aka note to future self):

  1. First, there is already a quite complex run loop (for openvpn and unbound for now). I would need to simplify it and ideally put tinyproxy and shadowsocks into that loop (long)
  2. Write an API to interact with with the loop (quick)
  3. Write a frontend for the API (quick)

So essentially i need to do some plumbing in 1. :smile: I'll update here once I make some progress.

qdm12 avatar Jun 29 '20 21:06 qdm12

Little update, I have done 1: now all subprocesses (openvpn, unbound, etc.) are in a 'loop'. I'll add a few API endpoints (2) in the coming 1-2 weeks.

qdm12 avatar Jul 08 '20 23:07 qdm12

Any update on this? I need to change regions periodically and it would be helpful to call a localhost request to change the region or IP address. Willing to Paypal $200 to prioritize this feature. Let me know, thanks.

smithb1994 avatar Aug 19 '22 19:08 smithb1994

Sorry for the immense delay.

0bb320065ef42228a98a9a5f16a453eb0ebbd0fa adds support for patching any of the vpn settings at runtime, using the http control server on port 8000. You can get (all) the current settings with curl http://localhost:8000/v1/vpn/settings, and you can patch the ones you want with for example:

curl -X PUT http://localhost:8000/v1/vpn/settings -H 'Content-Type: application/json' -d '{"Provider": {"ServerSelection": {"Countries": ["netherlands"]}}}'

Note this is not so well-tested, so patching some of the settings may break gluetun at runtime eventually (then please create another issue).

Let's keep this issue opened for now so you can play around with it. Once you're happy enough with it, I will document it in the wiki.

qdm12 avatar Aug 21 '22 23:08 qdm12

@qdm12: Sounds great!

Will this also work with custom OpenVPN configs? This would be really amazing.

d4h0 avatar Aug 22 '22 07:08 d4h0

@d4h0 I think you could bind mount multiple openvpn config files and change the config path via the api. If it's the same config file but with different ips, you could also (maybe) patch the openvpn EndpointIP which should override the remote ip you have in your config.

qdm12 avatar Aug 22 '22 11:08 qdm12

Thank you, @qdm12, I'll give that a try!

d4h0 avatar Aug 22 '22 17:08 d4h0

Thank you for this feature! Any way to just change the server? So the external IP can be updated without filtering anything

vk496 avatar Jun 04 '23 16:06 vk496

Hi I tried the curl command for PAI VPN and modify the regions. It comes back with a 200 OK status, but does not change the region. Is there another version of the API that I should be using?

parthmodi avatar Jul 25 '23 20:07 parthmodi

Hi - I tried to use this command to adjust the openvpn hostname and it is not working. Can you let me know if I am sending the curl command the correct way?

curl -X PUT http://192.168.86.48:8000/v1/vpn/settings
-H 'Content-Type: application/json'
-d '{"Provider": {"ServerSelection": {"hostnames": ["xxx.xxx.vpn.com"]}}}'

Output that is returned:

settings left unchanged

amatochristopher avatar Feb 26 '24 04:02 amatochristopher