LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-26-2018, 09:15 AM   #1
qwerewq
LQ Newbie
 
Registered: Mar 2010
Location: Lithuania, Vilnius, Pasilai
Distribution: Debian (testing)
Posts: 27

Rep: Reputation: 0
redirect all web traffic from network through proxy server to a specific URL


I have a network env, which has outgoing traffic using proxy only.

I want to create some sort of "unproxying GW" for my specific internal network.

I am okay to use any Linux based solution for this, such as nginx/apache, HAproxy, squid, iptables or any other.

Infra:
Code:
gw: 10.1.1.1
dns: 10.2.1.1
proxy: www-proxy.xxx

my server **with** ability to use proxy: 10.1.1.4
My server **without** proxy, but able to access 10.1.1.4 any port: 10.1.1.111
In the end I would like to request: http://10.1.1.4/subdir/file > which would go to http://www.museum/subdir/file over www-proxy.xxx (what is squid, if that matters).

any ideas?

----

for nginx, it is easy to make redirection to some specific URL, but how to set it to use proxy... that is most interesting thing I cannot get.

---

Small update:

App I am trying to use is:
Code:
screen -S vm virt-install --name VM --vcpus 4 --memory 4096 --location http://mirror.centos.org/centos-7/7/os/x86_64/
 --os-variant rhel7 --network network=mgmtbr,model=virtio --disk vol=LVM-pool/vmvol,device=disk,bus=virtio --virt-type kvm --graphics none --console pty --extra-args "console=ttyS0 ip=10.1.1.111::10.1.1.1:255.255.255.0:sel:eth0:none nameserver=10.1.1.1 nameserver=10.1.1.2 inst.proxy='http://www-proxy.xxx:8080/' inst.cmdline"
I do not want to install GUI to set it up.
It fails when trying to get "http://mirror.centos.org/centos-7/7/os/x86_64/LiveOS/squashfs.img", I think in between stage1 and stage2? looks like inst.proxy='http://www-proxy.xxx:8080/' is not set, but I can see IP there...

Last edited by qwerewq; 11-27-2018 at 10:59 AM.
 
Old 11-27-2018, 10:03 AM   #2
qwerewq
LQ Newbie
 
Registered: Mar 2010
Location: Lithuania, Vilnius, Pasilai
Distribution: Debian (testing)
Posts: 27

Original Poster
Rep: Reputation: 0
I am trying to use nginx here.

I use following additions to default centos config:
Code:
...
http {
    upstream centos {
        server mirror.centos.org;
    }
    resolver 10.2.1.1;
    resolver_timeout 5s;
...
        location / {
            proxy_request_buffering off;
#           proxy_redirect      http://127.0.0.1:8080 https://;
            proxy_pass http://mirror.centos.org/$uri$is_args$args; # used proxy_pass http://centos$uri$is_args$args;
            proxy_redirect http://www-proxy.xxx:8080/ /;
        }
...
cat /var/log/nginx/error.log output:
Code:
2018/11/27 16:59:51 [error] 47525#0: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: 127.0.0.1, server: _, request: "GET /centos-7/7/os/x86_64/ HTTP/1.1", upstream: "http://88.150.173.210:80//centos-7/7/os/x86_64/", host: "127.0.0.1"
And Curl output:
Code:
curl -v  http://127.0.0.1/centos-7/7/os/x86_64/
* About to connect() to 127.0.0.1 port 80 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET /centos-7/7/os/x86_64/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1
> Accept: */*
>
< HTTP/1.1 504 Gateway Time-out
< Server: nginx/1.12.2
< Date: Tue, 27 Nov 2018 15:57:29 GMT
< Content-Type: text/html
< Content-Length: 3693
< Connection: keep-alive
...
it looks like as I expect it to be, but now need to redirect nginx request to proxy server.
Have had idea on using systemd env variable, but not sure if I set it right or nginx ignores it...
Maybe nginx proxy_pass headers variables, but not sure how to... any ideas?

Last edited by qwerewq; 11-27-2018 at 10:09 AM. Reason: some additional oputputs from curl and error.log from nginx
 
Old 11-27-2018, 10:40 AM   #3
qwerewq
LQ Newbie
 
Registered: Mar 2010
Location: Lithuania, Vilnius, Pasilai
Distribution: Debian (testing)
Posts: 27

Original Poster
Rep: Reputation: 0
with haproxy I hit a different issue, but still no result achieved:
I have haproxy config:
Code:
frontend www-proxy
    bind *:80
    log global
    mode http
    use_backend         proxy-squid
    default_backend     proxy-squid

backend proxy-squid
    mode http
    option forwardfor
    option http-server-close
    server seliproxy www-proxy.xxx:8080
Yes, it redirects to proxy, but how to say proxy to fetch data from required url?!
 
Old 11-27-2018, 12:12 PM   #4
qwerewq
LQ Newbie
 
Registered: Mar 2010
Location: Lithuania, Vilnius, Pasilai
Distribution: Debian (testing)
Posts: 27

Original Poster
Rep: Reputation: 0
A workaround, which I am not happy, to place centos iso to the http, to fetch squashfs.img and continue with installation... but I do not like it...
 
  


Reply

Tags
centos, centos7, proxy, virsh



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Proxy all traffic through proxy anders_ Linux - Software 3 12-03-2017 07:29 AM
LXer: Redirect all (TCP) traffic through transparent socks5 proxy in Linux LXer Syndicated Linux News 0 01-28-2012 06:10 PM
Using Squid/Iptables to redirect inbound web traffic to url/IP winairmvs Linux - Software 2 01-13-2010 11:41 AM
Forwarding all traffic to the proxy to another proxy (transparent proxy/redirection) lakshithaww Linux - Networking 1 10-28-2009 12:54 AM
how can redirect specific ip to specific web page Barq Linux - Server 0 07-01-2009 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration