5

I am using Squid as a proxy server for web cache in my local network. I have developed a utility in VB.NET that requires a remote connection to a MySQL database on a remote server over internet. I am able to connect to remote server if I disable the proxy server but can not if the proxy is enabled.

I don't know if I can use MySql Proxy in this scenario on my local proxy server and what configurations will I have to make.

Below is my squid configuration;

ACL to define ports allowed to passthrough Squid
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 3306 # mysql remote connection
acl CONNECT method CONNECT

http_access deny !Safe_ports
http_access allow Safe_ports
http_access allow CONNECT !SSL_ports

What alternative I can have to achieve a similar setup that is web cache + remote connection to mysql database.

3 Answers 3

2

Squid can't proxy MySQL at all. You have to configure your firewall (or use direct connect, nat, etc) to use remote connection.

2
  • I do not have a firewall installed. Can you please guide what else I can do? Any more info on direct connect or nat? Thanks for the answer though.
    – Rafi
    Dec 20, 2012 at 11:54
  • I am making a .net application to connect to remote database.
    – Rafi
    Dec 20, 2012 at 12:41
1

I've been looking into proxying database traffic, too. Squid can't proxy MySQL traffic, but you do want to proxy MySQL traffic, you can try SQLProxy, which is an IIS plug-in to proxy MySQL traffic.

A Java-based solution that runs on Windows, Mac, and Linux is TcpCatcher. It's primarily intended to monitor and change TCP traffic, but it can also be used as a pure proxy server.

If you are open to a *nix-based solution, there's High Availability Proxy ("HAProxy"), which is as a TCP/HTTP load balancer, which can be used to proxy MySQL database connections as well as HTTP connections.

There's a tutorial and information page on using HAProxy to proxy MySQL connections at http://www.severalnines.com/resources/clustercontrol-mysql-haproxy-load-balancing-tutorial (as of June 2013). Here's an example of using HAProxy to proxy a single MySQL connection: http://flavio.tordini.org/a-more-stable-mysql-with-haproxy.

1
  • I want to mysql remote on my centos server through squids (idealy using mysql from windows CMD). Any solutions?
    – Yohanim
    Feb 17, 2020 at 14:56
0

I have managed to get it worked with Microsoft Forefront TMG. An access rule is to be created with a port 3306 outbound connection from internal to external for all the users. Firewall client should also be installed on client machines.

Squid and Polipo can not be used in an environment where remote connections to MySql are required. In such a scenario setting up a local server before proxy and some sync mechanism with the remote server or VPN/SSH is a possibility.

Hope it helps to other relevant readers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.