Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

Connecting to a git repo through a SOCKS proxy

Sometimes it has to be done.

Joel Clermont
Joel Clermont
2024-11-01

From our daily Laravel tips email. Get the next one in your inbox.

Yesterday, I shared on tip on how we connect to private git servers using SSH. But what do you do if the private server only supports HTTPS?

It can still be done, but it involves an extra step.

First, you need to set up a SOCKS proxy. This can be done with an SSH tunnel, just like we did with the SSH proxy:

ssh -ND 1080 our-proxy.server.com

Next, you need add some git configuration to use the SOCKS proxy for this host:

# ~/.gitconfig
[http "https://internal-git-server.client.com"]
        proxy = socks5://localhost:1080

Now, when you interact with this repo using git, it will automatically use the SOCKS proxy configuration. No extra command line options needed.

Ideally, you'd be able to use SSH for everything, but sometimes you have to work with what you're given.

Here to help,

Joel

P.S. Do you work alone and want someone to pair with on your Laravel app?

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.