This guide will help you configure a Raspberry Pi as a web proxy through OpenVPN.
Jump To…
Step 1: Assign a Reserved IP Address to Your Raspberry Pi
Step 2: Set Up the OpenVPN Configuration
Step 3: Install OpenVPN and Configure the Web Proxy
Step 4: Add the CyberGhost VPN Configuration Files
Step 5: Add your OpenVPN Credentials and Enable Automatic Startup
Requirements
Before you begin, make sure you have the following:
- A Raspberry Pi running Raspberry Pi OS
- A CyberGhost account and subscription
Disclaimer: We document each step as carefully as possible, but this process requires some technical knowledge. Interface options, firmware behavior, or setup steps may change as well, so check your router’s documentation if something doesn’t match the instructions.
Step 1: Assign a Reserved IP Address to Your Raspberry Pi
A reserved IP address means your router always gives your Raspberry Pi the same local IP address every time it connects. This is important because the web proxy setup relies on knowing exactly where your Raspberry Pi is on your network.
You set this up in your router's settings.
Open your router’s web interface and assign a reserved IP address to your Raspberry Pi. Check your router's documentation for instructions since the exact steps vary by model.
Step 2: Set Up the OpenVPN Configuration
- Open your CyberGhost VPN online account and log in with your username and password.
- Click on the VPN section from the left-side menu. Scroll down and then click on Configure Device next to Manual setup.
- Then, configure the settings for the Raspberry Pi device as follows:
-
Protocol: Select either:
- OpenVPN: The OpenVPN UDP default option can provide faster speeds than TCP, but it may cause interrupted downloads in some cases.
- OpenVPN TCP: The OpenVPN TCP option can provide more stable connections than UDP, but it may run slightly slower. Choose TCP if you experience recurring connection issues, such as sudden disconnections.
- Country: Select from the available VPN server locations.
- Server group: Select the appropriate server group.
- Click Save Configuration.
- You’ll be taken to the VPN tab. Select View next to the configuration for the Raspberry Pi device.
- Here, you’ll see the connection credentials and details, including:
- Username: The username generated for this configuration. This isn’t your regular CyberGhost account username. It only authenticates this manual configuration with CyberGhost VPN’s servers.
- Password: The password generated for this configuration. This isn’t your regular CyberGhost account password. It only authenticates this manual configuration with CyberGhost’s servers.
Important: Please keep your username and password obtained during the configuration process at hand; you’ll need them later in the setup.
- Next, select Download Configuration to download the configuration file to your computer.
It’s recommended to create a dedicated folder for the configuration files in an accessible location, like your desktop.
The saved configuration downloads as a .zip file containing the following files:
- ca.crt: The certificate authority file.
- client.crt: The client certificate file.
- client.key: The private key file.
- openvpn.ovpn: The OpenVPN configuration file.
Step 3: Install OpenVPN and Configure the Web Proxy
First, make sure your system is up to date and has the required packages installed.
- Open a terminal and run:
sudo apt-get update && sudo apt-get upgradeThis updates your Raspberry Pi's software to the latest version.
- Then run:
sudo apt-get install openvpn openssl openresolvThis installs the three tools you need: OpenVPN to run the VPN connection, OpenSSL to handle encryption, and openresolv to manage your DNS settings.
Then install Privoxy, the web proxy software that will route your network traffic through the VPN:
sudo apt-get install privoxyPrivoxy listens for connections on your Raspberry Pi's IP address and port 8118. You now need to update its configuration to use the IP address you assigned in step 1.
To check the current Privoxy settings:
- Open the Privoxy configuration file:
sudo nano /etc/privoxy/config- Look for the listen-address entry.
- In the Privoxy configuration file, scroll down to section 4.1. Change the listen-address entry to the IP address you assigned to your Raspberry Pi in your router settings. For example:
listen-address 192.168.178.24:8118- Save your changes, then restart the Raspberry Pi.
Test the Web Proxy Connection
Use another computer on the same local network as your Raspberry Pi to test the proxy connection.
- Open a browser on the other computer. We will use Firefox for this test. Click the menu icon in the top-right corner and select Settings.
- Under General settings, select Configure proxy.
- Enter your Raspberry Pi’s IP address as the proxy address. In this example, use 192.168.178.24. And enter 8118 as the port. Then, click OK to save the settings.
You should now be able to browse the internet through the Raspberry Pi web proxy.
Step 4: Add the CyberGhost VPN Configuration Files
Extract all files from the downloaded CyberGhost configuration .zip file. Rename openvpn.ovpn to a location-specific .conf file, such as CG_RO.conf, based on the country you selected.
Then, copy the configuration files to your OpenVPN directory on your Raspberry Pi.
- Open a terminal and go to the folder where you extracted the configuration files:
cd [path to configuration folder]- Copy the renamed OpenVPN configuration file:
sudo cp CG_RO.conf /etc/openvpn/- Copy the certificate and key files:
sudo cp ca.crt /etc/openvpn/
sudo cp client.crt /etc/openvpn/
sudo cp client.key /etc/openvpn/If you want to use more than one location
Each country requires its own configuration file. To add a new one:
- Go back to your CyberGhost account dashboard.
- Create a new configuration with a different country following the steps from step 2.
- Download the new configuration file and extract it.
- Then, rename the openvpn.ovpn file to something location-specific like CyberGhost_US.conf or CyberGhost_DE.conf so you can tell them apart.
- Copy the new .conf file to /etc/openvpn/.
Repeat these steps for each country you want to add.
Note: The other files (ca.crt, client.crt, and client.key) stay the same and don't need to be replaced.
Step 5: Add Your OpenVPN Credentials and Enable Automatic Startup
Navigate to the OpenVPN directory:
cd /etc/openvpn
Save Your CyberGhost VPN Credentials
To log in automatically:
- Create and open a new credentials file:
sudo nano user.txt
- Then, enter your generated username on the first line and your generated password on the second line. Don’t use your regular CyberGhost account credentials. Use the generated username and password from step 2.
- Save the file with Ctrl + O, then exit nano with Ctrl + X.
Update the Configuration File
- Open your OpenVPN configuration file, and replace CG_XX.conf with the name of your actual .conf file:
sudo nano CG_XX.conf- Find the auth-user-pass like and replace it with the path to your credentials file:
auth-user-pass /etc/openvpn/user.txt
- At the bottom of the configuration file, after verb 4, add these lines:
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf- Save the file with Ctrl + O, then exit nano with Ctrl + X.
Enable Automatic Startup
- Open the OpenVPN default settings file:
sudo nano /etc/default/openvpn- Add the following line. Replace CG_XX with the name of your .conf file without the .conf extension:
AUTOSTART="CG_XX"For example, if your configuration file is named CG_RO.conf, enter:
AUTOSTART="CG_RO"- Save the file with Ctrl + O, then exit nano with Ctrl + X.
- Then run these two commands to enable OpenVPN on startup and start it now:
sudo update-rc.d openvpn enablesudo service openvpn startStep 6: Test the Proxy Connection
Now that the VPN is configured, test the connection again to confirm that traffic is routing through both Privoxy and CyberGhost
On a separate device, such as a laptop or desktop, connected to the same home network as your Raspberry Pi, open a browser and go to the proxy settings. Enable manual proxy configuration in the browser, then enter the Privoxy web proxy address and port.
To confirm the proxy is working, visit https://whoer.net/. It should show the IP address of the CyberGhost server you selected.
Need assistance? Contact our Customer Support team:
- via email at support@cyberghost.ro
- via online request at https://support.cyberghostvpn.com/hc/en-us/requests/new
- via 24/7 Live Chat by clicking the Support button below
Comments
0 comments
Article is closed for comments.