How to use nginx as forward proxy in aws ec2

Viewed 17

I am trying to setup a environment where I have two VM's.

Scenaio would be like

VM1 and VM2 are there and VM one trying to reach internet (all outboud), it should forward the all traffic to VM1 (which has nginx running as forward proxy)

I created IP table rule in source VM (VM2) as below

iptables -t nat -A OUTPUT -p tcp -o eth1 --dport 80 -j DNAT --to proxyserverip:8888
iptables -t nat -A OUTPUT -p tcp -o eth1 --dport 443 -j DNAT --to proxyserver:8888

and in VM1(proxy VM running nginx) have below config. how ever this is not working as expected.

server {
    listen       8888;

    location / {
        resolver 8.8.8.8;
        proxy_pass http://$http_host$uri$is_args$args;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

I am trying this in aws ec2 using nat and internet gateways as below.

enter image description here

But unable to establish connection.

0 Answers
Related