Running a Proxy Server in US via OpenShift

I have received the following email from OpenShift. (I am sorry about this)

On Mar 06, 2017 at 04:58:14 PM the OpenShift operations team flagged your application.

We believe your use of OpenShift violates the Services Agreement and Acceptable Use Policy both of which can be found here: Violation: proxy server

Your applications have been removed. You can contact us at 'rhcloud-security@redhat.com'

The Red Hat OpenShift Team

First, download the python-proxy code. There is only a single file, PythonProxy.py.

Second, sign up for OpenShift, and you will get access to three free gears.

Next, install Git and the rhc client tools.
Then, run the following commands in a terminal.


    $ rhc domain create -n SubDomainName -l EmailAddress -p password


Change the EmailAddress and password to your OpenShift login email and password. This will create a namespace (sub-domain) for all your applications to be grouped under. The above example will make AppName-SubDomainName.rhcloud.com the public url for your applications with the AppName being replaced by your application name.

Create a new application using python template with:

    $ rhc app create -a AppName -t python-2.6


This will also create a git repository in your current directory.


    $ cd AppName


Copy the PythonProxy.py into the AppName folder. Modify PythonProxy.py by adding another import:

    import socket, thread, select
# for openshift env
import os


and change the last line to start the proxy using the OPENSHIFT_INTERNAL_IP address.

    if name == 'main':
start_server(host=os.environ['OPENSHIFT_INTERNAL_IP'], port=15000)


Run the following git commands:

    $ git add PythonProxy.py
$ git commit -a -m "initial commit of PythonProxy"
$ git push


This will push your changes back to your OpenShift server.

We are ready to start the PythonProxy in the OpenShift server.

    $ grep url .git/config
url = ssh://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@AppName-SubDomainName.rhcloud.com/~/git/AppName.git/
$ ssh xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@AppName-SubDomainName.rhcloud.com



    [AppName-SubDomainName.rhcloud.com ~]\> 
[AppName-SubDomainName.rhcloud.com ~]\> cd app-root/runtime/repo/
[AppName-SubDomainName.rhcloud.com repo]\> python PythonProxy.py &
[AppName-SubDomainName.rhcloud.com repo]\> exit
$



    $ rhc port-forward AppName
Password: *
 
Checking available ports...
Binding httpd -> 127.x.x.1:8080...
Binding python -> 127.x.x.1:15000...
Forwarding ports, use ctl + c to stop


This configures your local system to be able to connect to the remote services. It will display your OpenShift server ip address and port that are forwarded.

Now, enter your OpenShift server ip address and port 127.x.x.1:15000 as your local web browser proxy server setting.

Because the OpenShift server (using Amazon) is in US, this effectively allows you to access web resources restricted by geography.

Guide to buying Amazon mp3, ebooks, videos and downloads outside of USA

Comments

blog comments powered by Disqus