Как установить прокси HTTP/S для доступа к Интернету

Я имею, имеют две машины Ubuntu:

  • С доступом к B, но без доступа к Интернету
  • B с с доступом к Интернету

Я обеспечиваю доступ к Интернету на машине, я хотел бы установить прокси HTTP/HTTPS на машине B и настроить завихрение, и склонный - добираются для использования этого прокси.

На B я настроил nginx из изображения докера следующим образом:

docker run -d \
  --name nginx-auto-ssl \
  --restart on-failure \
  -p 80:80 \
  -p 443:443 \
  -e ALLOWED_DOMAINS=* \
  -e FORCE_HTTPS=false \
  valian/docker-nginx-auto-ssl

На мне установил прокси

 export http_proxy=http://machine.b.com:80/
 export https_proxy=https://machine.b.com:443/

Однако, когда я запрашиваю интернет-ресурс от A, я добираюсь, информационный прокси не настроен:

curl http://www.facebook.com/ -v
* Hostname was NOT found in DNS cache
*   Trying 172.25.10.202...
* Connected to machine.b.com (172.x.x.x) port 80 (#0)
> GET http://www.facebook.com/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.facebook.com
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
* Server openresty/1.13.6.1 is not blacklisted
< Server: openresty/1.13.6.1
< Date: Tue, 29 May 2018 12:52:38 GMT
< Content-Type: text/html
< Content-Length: 562
< Last-Modified: Fri, 20 Apr 2018 14:42:38 GMT
< Connection: keep-alive
< ETag: "5ad9fc5e-232"
< Accept-Ranges: bytes
<
<!DOCTYPE html>
<html>
<head>
<title>Welcome to OpenResty!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to OpenResty!</h1>
<p>If you see this page, the OpenResty web platform is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="https://openresty.org/">openresty.org</a>.<br/></p>

<p><em>Thank you for flying OpenResty.</em></p>
</body>
</html>
-1
задан 29 May 2018 в 07:28

1 ответ

В отличие от некоторых требуемых, возможно сделать это с прокси nginx.

Вот docker-compose.yml:

version: '3'

services:
  nginx_proxy:
    container_name: "proxy"
    image: reiz/nginx_proxy:latest
    ports:
      - 8888:8888
    volumes:
      - ./nginx.conf:/usr/local/nginx/conf/nginx.conf:ro

Вот nginx.conf:

user www-data;
worker_processes auto;
daemon off; # Don't run Nginx as daemon, as we run it in Docker we need a foreground process.
events {}

http {
  server_names_hash_bucket_size 128;

  access_log /var/log/nginx_access.log;
  error_log /var/log/nginx_errors.log;

  # Whitelist Google and Heise
  server {
    listen 8888;
    proxy_connect;
    proxy_max_temp_file_size 0;
    resolver 8.8.8.8;
    location / {
      proxy_pass http://$http_host;
        proxy_set_header Host $http_host;
    }
  }

}
0
ответ дан 29 October 2019 в 05:57

Другие вопросы по тегам:

Похожие вопросы: