Como configurar o proxy HTTP / S para acessar a Internet

-1

Eu tenho duas máquinas Ubuntu:

  • A com acesso a B, mas sem acesso à Internet
  • B com acesso à Internet

Eu forneço acesso à Internet na máquina A Eu gostaria de configurar o proxy HTTP / HTTPS na máquina B e configurar o curl e o apt-get para usar este proxy.

Em B, configurei o nginx a partir da imagem do docker da seguinte forma:

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

Em um conjunto de proxies

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

No entanto, quando eu solicito o recurso da Internet de A, recebo o proxy de informações que não está configurado:

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>
    
por dzieciou 29.05.2018 / 16:28

1 resposta

0

Ao contrário de alguns reivindicados, é possível fazê-lo com o proxy nginx.

Aqui está o 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

Aqui está o 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;
    }
  }

}
    
por dzieciou 04.06.2018 / 14:05