Iptables reroute to shadowsocks
I have ubuntu 20.04 vps with shadow-socks server on it.
I also have ubuntu 20.04 on my pc, with shadow-socks client running on it.
Currently using shadow-socks-libev version.
The goal is to redirect all requests to 127.0.0.1:1080, where proxy client is running.
I followed recommendations from this question and this blog, where the answer is pointing to.
Also saw this qna.
However, nothing made it work for me.
Steps I made
I. I created admin user for running shadow socks client only.
II. I made systemd unit to start client on boot from separate user, content of file listed below:
[Unit]
Description=SahdowSocks
After=network.target
After=network-online.target
[Service]
ExecStart=ss-local -c /etc/shadowsocks-client/config.json
Restart=on-failure
User=socks_user
Group=socks_user
[Install]
WantedBy=multi-user.target
At this point if I'm setting 127.0.0.1:1080 in my browser (firefox) as a socks5 proxy - it works fine.
III. Then I made iptables rules, according to the links above.
sudo iptables -t nat -A OUTPUT -p tcp -m owner ! --uid-owner socks_user --dport 80 -j REDIRECT --to-port 1080
sudo iptables -t nat -A OUTPUT -p tcp -m owner ! --uid-owner socks_user --dport 443 -j REDIRECT --to-port 1080
After that, I can still use the browser if connected directly to the proxy through settings, but after switching to no proxy/system proxy - getting request timeout. All other apps also have no connection.
*Just to mention, if I do ping to 1.1.1.1 it returns fine
*If I do wget http://someurl it ends with no result.
So I assume I'm getting reroute loop (?), but don't understand why.