Skip to content

Instantly share code, notes, and snippets.

@bravery9
Forked from yougg/proxy.md
Created February 21, 2020 05:03
Show Gist options
  • Save bravery9/ac487db6162be1ae2e943d9e5c21e204 to your computer and use it in GitHub Desktop.
Save bravery9/ac487db6162be1ae2e943d9e5c21e204 to your computer and use it in GitHub Desktop.

Revisions

  1. @yougg yougg revised this gist Feb 7, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -81,6 +81,7 @@ unset {http,https,ftp,rsync,all}_proxy {HTTP,HTTPS,FTP,RSYNC,ALL}_PROXY

    git config --global --unset http.proxy
    git config --global --unset https.proxy
    git config --global --unset core.sshCommand

    git config --global --unset http.https://github.com.proxy

  2. @yougg yougg revised this gist Feb 7, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -55,6 +55,9 @@ export ssh_proxy='ProxyCommand=connect -S PROXYHOST:PROXYPORT %h %p'

    # connect to ssh server over proxy
    ssh -o "$ssh_proxy" USER@FINAL_DEST

    # set git ssh proxy
    git config --global core.sshCommand "ssh -o $ssh_proxy"
    ```

    # set no proxy to ignore private network address
  3. @yougg yougg revised this gist Sep 14, 2018. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,3 @@
    # set no proxy to ignore private network address

    ```bash
    no_proxy="127.0.0.1,localhost,.localdomain.com"
    no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0..255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0..255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 192.168.{0..255}.{0..255}|tr ' ' ','`
    export no_proxy
    # for more private network addresses, check following url
    # https://segmentfault.com/q/1010000010521593
    # https://en.wikipedia.org/wiki/Private_network
    ```

    # set http or socks proxy

    ```bash
    @@ -70,6 +57,19 @@ export ssh_proxy='ProxyCommand=connect -S PROXYHOST:PROXYPORT %h %p'
    ssh -o "$ssh_proxy" USER@FINAL_DEST
    ```

    # set no proxy to ignore private network address

    ```bash
    no_proxy="127.0.0.1,localhost,.localdomain.com"
    no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0..255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0..255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 192.168.{0..255}.{0..255}|tr ' ' ','`
    export no_proxy
    # for more private network addresses, check following url
    # https://segmentfault.com/q/1010000010521593
    # https://en.wikipedia.org/wiki/Private_network
    ```

    # unset proxy

    ```bash
  4. @yougg yougg revised this gist Sep 14, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@

    ```bash
    no_proxy="127.0.0.1,localhost,.localdomain.com"
    no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0.255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0.255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 192.168.{0..255}.{0.255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0..255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0..255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 192.168.{0..255}.{0..255}|tr ' ' ','`
    export no_proxy
    # for more private network addresses, check following url
    # https://segmentfault.com/q/1010000010521593
  5. @yougg yougg revised this gist Sep 14, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@

    ```bash
    no_proxy="127.0.0.1,localhost,.localdomain.com"
    no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0.255}|tr ' ' ','`"
    no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0.255}|tr ' ' ','`"
    no_proxy=$no_proxy,`echo 192.168.{0..255}.{0.255}|tr ' ' ','`"
    no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0.255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0.255}|tr ' ' ','`
    no_proxy=$no_proxy,`echo 192.168.{0..255}.{0.255}|tr ' ' ','`
    export no_proxy
    # for more private network addresses, check following url
    # https://segmentfault.com/q/1010000010521593
  6. @yougg yougg revised this gist Sep 14, 2018. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,16 @@
    # set no proxy to ignore private network address

    ```bash
    no_proxy="127.0.0.1,localhost,.localdomain.com"
    no_proxy=$no_proxy,`echo 10.{0..255}.{0..255}.{0.255}|tr ' ' ','`"
    no_proxy=$no_proxy,`echo 172.{16..31}.{0..255}.{0.255}|tr ' ' ','`"
    no_proxy=$no_proxy,`echo 192.168.{0..255}.{0.255}|tr ' ' ','`"
    export no_proxy
    # for more private network addresses, check following url
    # https://segmentfault.com/q/1010000010521593
    # https://en.wikipedia.org/wiki/Private_network
    ```
    # set http or socks proxy
    ```bash
    @@ -23,8 +36,6 @@ all_proxy=$http_proxy
    # export other env variables (another way)
    export {https,ftp,rsync,all}_proxy=$http_proxy
    export no_proxy="127.0.0.1,localhost,.localdomain.com,`echo 10.1.{1..255}.{1.255}|tr ' ' ','`"

    export HTTP_PROXY=$http_proxy \
    HTTPS_PROXY=$http_proxy \
    FTP_PROXY=$http_proxy \
  7. @yougg yougg revised this gist Aug 20, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion proxy.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # set http proxy
    export http_proxy=http://127.0.0.1:8080
    # set http proxy with user and password
    export http_proxy=http://USERNAME:PASSWORD`@127.0.0.1:8080
    export http_proxy=http://USERNAME:[email protected]:8080
    # set http proxy with user and password (with special characters)
    export http_proxy=http://`urlencode 'USERNAME'`:`urlencode 'PASSWORD'`@127.0.0.1:8080

  8. @yougg yougg revised this gist Aug 19, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -63,6 +63,7 @@ ssh -o "$ssh_proxy" USER@FINAL_DEST

    ```bash
    unset http_proxy https_proxy ftp_proxy rsync_proxy all_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY ALL_PROXY
    unset {http,https,ftp,rsync,all}_proxy {HTTP,HTTPS,FTP,RSYNC,ALL}_PROXY
    git config --global --unset http.proxy
    git config --global --unset https.proxy
  9. @yougg yougg revised this gist Aug 19, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -3,17 +3,25 @@
    ```bash
    # set http proxy
    export http_proxy=http://127.0.0.1:8080
    # set http proxy with user and password
    export http_proxy=http://USERNAME:PASSWORD`@127.0.0.1:8080
    # set http proxy with user and password (with special characters)
    export http_proxy=http://`urlencode 'USERNAME'`:`urlencode 'PASSWORD'`@127.0.0.1:8080
    # set socks proxy (local DNS)
    export http_proxy=socks5://127.0.0.1:1080
    # set socks proxy (remote DNS)
    export http_proxy=socks5h://127.0.0.1:1080
    ```

    ```bash
    # export other env variables
    export https_proxy=$http_proxy \
    ftp_proxy=$http_proxy \
    rsync_proxy=$http_proxy \
    all_proxy=$http_proxy
    # export other env variables (another way)
    export {https,ftp,rsync,all}_proxy=$http_proxy
    export no_proxy="127.0.0.1,localhost,.localdomain.com,`echo 10.1.{1..255}.{1.255}|tr ' ' ','`"
    @@ -23,6 +31,7 @@ FTP_PROXY=$http_proxy \
    RSYNC_PROXY=$http_proxy \
    ALL_PROXY=$http_proxy \
    NO_PROXY=$no_proxy
    export {HTTP,HTTPS,FTP,RSYNC,ALL}_PROXY=$http_proxy
    # set git http(s) proxy
    git config --global http.sslverify false
  10. @yougg yougg revised this gist Aug 19, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ ftp_proxy=$http_proxy \
    rsync_proxy=$http_proxy \
    all_proxy=$http_proxy

    export no_proxy="127.0.0.1,localhost,localaddress,.localdomain.com"
    export no_proxy="127.0.0.1,localhost,.localdomain.com,`echo 10.1.{1..255}.{1.255}|tr ' ' ','`"

    export HTTP_PROXY=$http_proxy \
    HTTPS_PROXY=$http_proxy \
    @@ -47,7 +47,7 @@ export ssh_proxy='ProxyCommand=connect -H PROXYHOST:PROXYPORT %h %p'
    export ssh_proxy='ProxyCommand=connect -S PROXYHOST:PROXYPORT %h %p'

    # connect to ssh server over proxy
    ssh -o $ssh_proxy USER@FINAL_DEST
    ssh -o "$ssh_proxy" USER@FINAL_DEST
    ```

    # unset proxy
  11. @yougg yougg created this gist Aug 19, 2018.
    64 changes: 64 additions & 0 deletions proxy.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    # set http or socks proxy

    ```bash
    # set http proxy
    export http_proxy=http://127.0.0.1:8080
    # set socks proxy (local DNS)
    export http_proxy=socks5://127.0.0.1:1080
    # set socks proxy (remote DNS)
    export http_proxy=socks5h://127.0.0.1:1080
    ```

    ```bash
    export https_proxy=$http_proxy \
    ftp_proxy=$http_proxy \
    rsync_proxy=$http_proxy \
    all_proxy=$http_proxy

    export no_proxy="127.0.0.1,localhost,localaddress,.localdomain.com"

    export HTTP_PROXY=$http_proxy \
    HTTPS_PROXY=$http_proxy \
    FTP_PROXY=$http_proxy \
    RSYNC_PROXY=$http_proxy \
    ALL_PROXY=$http_proxy \
    NO_PROXY=$no_proxy

    # set git http(s) proxy
    git config --global http.sslverify false
    git config --global http.proxy $http_proxy
    git config --global https.proxy $http_proxy

    # only for 'github.com'
    git config --global http.https://github.com.proxy $http_proxy
    ```

    # set ssh proxy

    ```bash
    # use 'nc' with http protocol
    export ssh_proxy='ProxyCommand=nc -X connect -x PROXYHOST:PROXYPORT %h %p'
    # use 'nc' with socks5 protocol
    export ssh_proxy='ProxyCommand=nc -X 5 -x PROXYHOST:PROXYPORT %h %p'

    # use 'connect' with http protocol
    export ssh_proxy='ProxyCommand=connect -H PROXYHOST:PROXYPORT %h %p'
    # use 'connect' with socks5 protocol
    export ssh_proxy='ProxyCommand=connect -S PROXYHOST:PROXYPORT %h %p'

    # connect to ssh server over proxy
    ssh -o $ssh_proxy USER@FINAL_DEST
    ```

    # unset proxy

    ```bash
    unset http_proxy https_proxy ftp_proxy rsync_proxy all_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY ALL_PROXY

    git config --global --unset http.proxy
    git config --global --unset https.proxy

    git config --global --unset http.https://github.com.proxy

    unset ssh_proxy
    ```