Configure Squid Proxy for Multiple Outgoing IP Addresses

Setup Your Own Multiple-IP, Private Group of Proxies on a Single VPS Installation

After much researching online in forum discussions and some hair-pulling troubleshooting (and a nudge in the right direction from Ralf at Tradebit), we’ve assembled a fairly reliable set of instructions for configuring Squid Proxy to employ multiple outgoing IP addresses from a single Squid installation and (this is the key) allowing you to connect through any of the outbound IP addresses depending on the IP address by which you connect to the Squid Cache server.

Squid CacheThere are a few incomplete ways to do this. Some of the existing tutorials like this one go only part of the way: they let client A from one IP address can connect through one outgoing IP address, and client B from a second IP address can connect through another outgoing IP address. This is limiting: client A can only use one outgoing IP. With our setup, we can use any of our many outgoing IP addresses.

Our Setup & Plan

We run Squid Cache on a basic VPS service running Linux. We are using Squid-3.2.1. Our VPS has six IP addresses, so we want to receive clients on any six of those IP addresses and direct Squid to use the same corresponding IP address for its outgoing connections. Because our VPS listens on all six IP addresses, we will designate separate ports for each inbound connection. It’s probably worth mentioning that we aren’t caching anything–we are simply using squid as a proxy.

Configuration

Obviously, we’ll be modifying the squid.conf file. We’ll be using the following configuration directives:

  • http_port
  • name=
  • myportname
  • acl
  • http_access
  • tcp_outgoing_address

First, we want to tell Squid what IPs and ports to listen on, and we want to use the “name=” option with http_port:

# Squid normally listens to port 3128
http_port 67.xxx.108.128:3128 name=3128
http_port 67.xxx.108.79:3129 name=3129
http_port 67.xxx.108.80:3130 name=3130
http_port 67.xxx.108.221:3131 name=3131
http_port 208.xxx.34.154:3132 name=3132
http_port 208.xxx.34.32:3133 name=3133

We just asked Squid to listen on sequential ports and to designate a name for each inbound connection.  Now that we’ve named the inbound connections, we can designate an ACL based on each inbound connection name and assign an outgoing IP to each:

acl tasty3128 myportname 3128 src 24.xxx.210.0/24
http_access allow tasty3128
tcp_outgoing_address 67.xxx.108.128 tasty3128

acl tasty3129 myportname 3129 src 24.xxx.210.0/24
http_access allow tasty3129
tcp_outgoing_address 67.xxx.108.79 tasty3129

acl tasty3130 myportname 3130 src 24.xxx.210.0/24
http_access allow tasty3130
tcp_outgoing_address 67.xxx.108.80 tasty3130

acl tasty3131 myportname 3131 src 24.xxx.210.0/24
http_access allow tasty3131
tcp_outgoing_address 67.xxx.108.221 tasty3131

acl tasty3132 myportname 3132 src 24.xxx.210.0/24
http_access allow tasty3132
tcp_outgoing_address 208.xxx.34.154 tasty3132

acl tasty3133 myportname 3133 src 24.xxx.210.0/24
http_access allow tasty3133
tcp_outgoing_address 208.xxx.34.32 tasty3133

That’s it. You should now be able to connect to any of your six IP addresses through Squid.

 

WordPress Stripping iFrame Elements? Here’s the Fix.

Elements like Google Map embeds get stripped out. Here’s the Fix.

If you have ever tried to enter a Google Map embed into a WordPress page or post, you’ve noticed that switching between “Visual” and “HTML” view in the page or post edit window strips the iFrame out–leaving you with broken code that displays nothing. Luckily, there is a fix.

You’ll need to find the functions.php file in your active theme folder. It’s a standard WordPress file, so it’ll be there. Next, we are going to add two short functions that change the way the WordPress editor handles iFrame code. You’ll want to insert the following lines of code before the closing “?>”  of your functions.php file.

// this function initializes the iframe elements 

function add_iframe($initArray) {
$initArray['extended_valid_elements'] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]";
return $initArray;
}

// this function alters the way the WordPress editor filters your code
add_filter('tiny_mce_before_init', 'add_iframe');

That’s it. You can test your mod by entering some iFrame code in the editor window and switching between  the visual and HTML editor.

MySQL String to Replace Postal Codes With State Names

I recently had to modify a mySql database to replace postal codes (i.e., “FL”) with complete state names (i.e., “Florida”). I searched all over and did not find a ready-made string to accomplish this.

I am sure somewhere that someone will find this useful.

Simply replace “dbo_vwPRVDR” with your table name, and “State” with the column name, and you’ll be in business.

update dbo_vwPRVDR set State = replace(State,'AL','Alabama');
update dbo_vwPRVDR set State = replace(State,'AK','Alaska');
update dbo_vwPRVDR set State = replace(State,'AZ','Arizona');
update dbo_vwPRVDR set State = replace(State,'AR','Arkansas');
update dbo_vwPRVDR set State = replace(State,'CA','California');
update dbo_vwPRVDR set State = replace(State,'CO','Colorado');
update dbo_vwPRVDR set State = replace(State,'CT','Connecticut');
update dbo_vwPRVDR set State = replace(State,'DC','Washington DC');
update dbo_vwPRVDR set State = replace(State,'DE','Delaware');
update dbo_vwPRVDR set State = replace(State,'FL','Florida');
update dbo_vwPRVDR set State = replace(State,'GA','Georgia');
update dbo_vwPRVDR set State = replace(State,'HI','Hawaii');
update dbo_vwPRVDR set State = replace(State,'IA','Iowa');
update dbo_vwPRVDR set State = replace(State,'ID','Idaho');
update dbo_vwPRVDR set State = replace(State,'IL','Illinois');
update dbo_vwPRVDR set State = replace(State,'IN','Indiana');
update dbo_vwPRVDR set State = replace(State,'KS','Kansas');
update dbo_vwPRVDR set State = replace(State,'KY','Kentucky');
update dbo_vwPRVDR set State = replace(State,'LA','Louisiana');
update dbo_vwPRVDR set State = replace(State,'MA','Massachusetts');
update dbo_vwPRVDR set State = replace(State,'MD','Maryland');
update dbo_vwPRVDR set State = replace(State,'ME','Maine');
update dbo_vwPRVDR set State = replace(State,'MI','Michigan');
update dbo_vwPRVDR set State = replace(State,'MN','Minnesota');
update dbo_vwPRVDR set State = replace(State,'MO','Missouri');
update dbo_vwPRVDR set State = replace(State,'MS','Mississippi');
update dbo_vwPRVDR set State = replace(State,'NC','North Carolina');
update dbo_vwPRVDR set State = replace(State,'ND','North Dakota');
update dbo_vwPRVDR set State = replace(State,'NE','Nebraska');
update dbo_vwPRVDR set State = replace(State,'NH','New Hampshire');
update dbo_vwPRVDR set State = replace(State,'NJ','New Jersey');
update dbo_vwPRVDR set State = replace(State,'NM','New Mexico');
update dbo_vwPRVDR set State = replace(State,'NV','Nevada');
update dbo_vwPRVDR set State = replace(State,'NY','New York');
update dbo_vwPRVDR set State = replace(State,'OH','Ohio');
update dbo_vwPRVDR set State = replace(State,'OK','Oklahoma');
update dbo_vwPRVDR set State = replace(State,'OR','Oregon');
update dbo_vwPRVDR set State = replace(State,'PA','Pennsylvania');
update dbo_vwPRVDR set State = replace(State,'PR','Puerto Rico');
update dbo_vwPRVDR set State = replace(State,'RI','Rhode Island');
update dbo_vwPRVDR set State = replace(State,'SC','South Carolina');
update dbo_vwPRVDR set State = replace(State,'SD','South Dakota');
update dbo_vwPRVDR set State = replace(State,'TN','Tennessee');
update dbo_vwPRVDR set State = replace(State,'TX','Texas');
update dbo_vwPRVDR set State = replace(State,'UT','Utah');
update dbo_vwPRVDR set State = replace(State,'VA','Virginia');
update dbo_vwPRVDR set State = replace(State,'VT','Vermont');
update dbo_vwPRVDR set State = replace(State,'WA','Washington');
update dbo_vwPRVDR set State = replace(State,'WI','Wisconsin');
update dbo_vwPRVDR set State = replace(State,'WV','West Virginia');
update dbo_vwPRVDR set State = replace(State,'WY','Wyoming');