Create TOC

레이블이 proxy인 게시물을 표시합니다. 모든 게시물 표시
레이블이 proxy인 게시물을 표시합니다. 모든 게시물 표시

2020년 3월 4일

Andriod/자동 프록시 설정시 Goolge Play Store나 YouTube가 동작하지 않는 문제 수정

Andriod 기기에서 자동 프록시 (pac)를 설정하면 Google Play Store나 YouTube가 동작하지 않는다. 이때는 설정 - 앱 및 알림 - 배터리 최적화 (Optimize battery) 대상에서 ProxyHandler를 빼면 된다(최적화 하지 않음).

2020년 1월 3일

Raspbian/docker + GreenTunnel

raspbian에서 GreenTunnel을 docker로 올리는 방법을 기술한다.

docker image 만들기

GreenTunnel 소스를 받는다

$ git clone https://github.com/SadeghHayeri/GreenTunnel GreenTunnel

GreenTunnel/Dockerfile 파일에서 FROM 부분을 아래와 같이 수정한다.

FROM node:lts-buster-slim

이미지를 빌드한다.

$ cd GreenTunnel
$ sudo docker build --tag green-tunnel ./

이미지가 생성되었는지 확인한다.

$ sudo docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
green-tunnel                  latest              e0f67216c1d5        19 hours ago        158MB
node                          lts-buster-slim     b490682c0125        5 days ago          134MB

docker-compose.yml

version: "3"

services:
    green-tunnel:
        container_name: green-tunnel
        image: green-tunnel
        ports:
            - "8000:8000/tcp"
        restart: unless-stopped

docker-compose 명령으로 container를 만든다.

$ sudo docker-compose up -d

테스트

GreenTunnel을 실행시킨 raspberry pi의 ip와 port 8000 으로Firefox 등의 웹 브라우저의 proxy 설정에서 https proxy를 설정한다.

GreenTunnel 로그는 아래 명령으로 확인할 수 있다.

$ sudo docker logs -f green-tunnel

proxy.pac

이제 원하는 사이트에 접속할 때만 GreenTunnel 을 사용하도록 자동 프록시 설정 파일(proxy.pac)을 만든다.

예제는 https://abc*.net, https://def.net, 접속에서만 GreenTunnel을 사용하도록 설정했다.

function FindProxyForURL(url, host) {
    url = url.toLowerCase();
    host = host.toLowerCase();

    isHttp=(url.substring(0, 5) == "http:");

    if (isHttp) {
        return "DIRECT";
    }

    if (0
        || isPlainHostName(host)
        || shExpMatch(host, "*.local")
        || isInNet(dnsResolve(host), "10.0.0.0", "255.0.0.0")
        || isInNet(dnsResolve(host), "172.16.0.0",  "255.240.0.0")
        || isInNet(dnsResolve(host), "192.168.0.0", "255.255.0.0")
        || isInNet(dnsResolve(host), "127.0.0.0", "255.255.255.0")
        ) {
        return "DIRECT";
    }

    if (0
        || shExpMatch(url, "https://abc*.net/*")
        || shExpMatch(url, "https://def.net/*")
        ) {
        return "PROXY GreenTunnel주소:8000";
    }
    return "DIRECT";
}

proxy.pac을 http 로 접속 가능한 위치에 올리고 원하는 브라우저나 시스템 설정에서 http://어딘가/proxy.pac 형식으로 자동 프록시를 등록하면 된다.

2019년 6월 26일

web proxy server를 경유해서 ssh 접속하기

아래와 같이 web proxy server를 경유해서 ssh server에 접속하는 방법을 적는다.

PC -> Web Proxy Server ----------> nginx(testserver:8888) -> ssh server(testserver:22)

서버 설정

패키지 설치

$ sudo apt install nginx-light libnginx-mod-stream
$ sudo mkdir /etc/nginx/stream-enabled

nginx 설정

/etc/nginx/nginx.conf에 아래와 같은 내용을 추가한다.

stream {
        include /etc/nginx/stream-enabled/*;
}

/etc/nginx/stream-enabled/test.conf 파일을 만든다.

upstream ssh {
        server 127.0.0.1:22;
}

server {
        listen 8888;
        proxy_pass ssh;
}

설정이 바르게 되었는지 확인한다.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

nginx를 다시 시작한다.

$ sudo systemctl restart nginx.service

접속 방법

linux

$ ssh -p 8888 foo@testserver -o "ProxyCommand=nc -X connect -x proxyserver:proxyport %h %p"

~/.ssh/config을 만들어 두는 것이 더 편하다.

Host myfoo
        Hostname testserver
        User foo
        Port 8888
        ProxyCommand    nc -X connect -x proxyserver:proxyport %h %p
$ ssh myfoo

Windows

PuTTY 의 proxy 설정을 이용한다.