How to create a personal piratebay proxy

You need a VPS. Boot it up, login as root:
cd /root
apt-get install libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev gcc make git socat screen
wget http://nginx.org/download/nginx-1.11.13.tar.gz
tar xvf nginx-1.11.13.tar.gz
git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
tar xzvf nginx-nginx-1.10.3.tar.gz
cd ~/nginx-1.11.13
./configure –with-http_ssl_module –add-module=~/ngx_http_substitutions_filter_module
make && make install
cd /usr/local/nginx/
./sbin/nginx

Test by going to the ip address of host.

cd /usr/local/nginx/conf
mv nginx.conf nginx.conf-backup
emacs nginx.conf

Add the code:

worker_processes auto;
events {
  worker_connections 1024;
}
http {
  include  mime.types;
  default_type application/octet-stream;
  sendfile on;
  gzip on;
  server {
    listen 80;
    server_name server_ip;

    location / {
    proxy_pass http://127.0.0.1:81/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
	}
  }
}

Start nginx after stopping it:

/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx

Create a daemon:

emacs ~/socat.sh
#!/bin/bash
socat tcp4-LISTEN:81,reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:127.0.0.1:uj3wazyk5u4hnvtk.onion:80,socksport=9050

Run the daemon

screen -A -m -d -S SOCAT_DAEMON ~/socat.sh

To start it at boot, add to /etc/rc.local

/username/socat.sh

Enjoy

Credits:
1. https://proxybay.one/setup.html
2. http://tor.stackexchange.com/questions/13792/how-can-i-nginx-reverse-proxy-to-onion-site-which-is-on-tor-network/13884


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Solve wordpress error: exceeds the maximum upload size for this site.

If you tried to upload a big file in WordPress and came across this error “exceeds the maximum upload size for this site”, this is for you.

This has nothing to do with WordPress and is a php.ini resource limit set by the server. If you are in a shared hosting environment with no access to editing php.ini, woe on you. There’s nothing you can do. Get a VPS or dedicated server!

On a VPS or dedi, the first step in fixing the issue is determining which php.ini is the cause of this, as there may be many. For this, create a file with the following content:

<?php
phpinfo();
?>

Name it as phpinfo.php and run it on you site. It will show you the resource limits, and the php.ini file which caused this. Once you locate the correct php.ini, edit it and change the values for these variables: upload_max_filesize and post_max_size. Yes both of them need to be increased.
Save the php file and you’ll notice the changes right away. If not restart the apache (or nginx) server with:

service apache2 restart

Note that on Webmin, each Virtualmin virtual server has a seperate php.ini file. You can edit it at Virtualmin>Services>php5 configuration>Resource limits


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Installing mailcow mail server suite

So, Mailcow seems to be a new kid on the block of mail servers. In this post, I’ll attempt to perform an installation of a freshly installed DigitalOcean droplet. (Digitalocean provides resizable VPSes that are useful to perform development and hobbyist work like this. )

Step 1:
Create a Dogital Ocean droplet. I’ll try the minimum size of droplet.

Step 2:
Login to the VPS as root. I’ll assume that you’ve installed your favorite text editor. I’ll be using emacs.

wget -O – https://github.com/andryyy/mailcow/archive/v0.11.tar.gz | tar xfz –
Substitute 0.11 with the latest release number from https://github.com/andryyy/mailcow/releases/latest

emacs mailcow.config

Edit it with your own values. It’s a piece of cake.

After running the install, I got an error:

+ DEBIAN_FRONTEND=noninteractive
+ apt-get --force-yes -y install zip jq dnsutils python-setuptools libmail-spf-perl libmail-dkim-pertp php-net-socket php-net-url php-pear php-soap php5 php5-cli php5-common php5-curl php5-fpm php5-gdent mysql-server nginx-extras mailutils pyzor razor postfix-mysql postfix-pcre spamassassin spamc surl libmime-base64-urlsafe-perl libtest-tempdir-perl liblogger-syslog-perl bsd-mailx
E: Unable to correct problems, you have held broken packages.
+ '[' 100 -ne 0 ']'
++ redb '[ERR]'
+++ tput bold
+++ tput setaf 1
+++ tput sgr0
++ echo '[ERR]'
+ echo '[ERR] - Package installation failed'
[ERR] - Package installation failed
+ exit 1

I tried running the command manually:

apt-get --force-yes -y install zip jq dnsutils python-setp-mail-mimedecode php-net-dime php-net-smtp php-net-socket php-net-url php-pear php-soap php5 php5-c5-sqlite libawl-php php5-xmlrpc mysql-client mysql-server nginx-extras mailutils pyzor razor postfixtchmail liblockfile-simple-perl libdbi-perl libmime-base64-urlsafe-perl libtest-tempdir-perl liblogg
Reading package lists... Done
Building dependency tree
Reading state information... Done
bzip2 is already the newest version.
curl is already the newest version.
curl set to manually installed.
libdbi-perl is already the newest version.
libdbi-perl set to manually installed.
mysql-client is already the newest version.
openssl is already the newest version.
openssl set to manually installed.
python-setuptools is already the newest version.
python-setuptools set to manually installed.
unzip is already the newest version.
unzip set to manually installed.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postfix-mysql : Depends: postfix (= 2.11.3-1) but it is not going to be installed
 postfix-pcre : Depends: postfix (= 2.11.3-1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

So I determined the problematic line:

$grep -inr 'install zip jq dnsutils' *
includes/functions.sh:245:DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y install zip jq dnsut

Edited the line to add postfix to the installation list, and reran installation:

[[email protected]] ~/build/mailcow-0.11 $emacs includes/functions.sh
[[email protected]] ~/build/mailcow-0.11 $./install.sh

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Configure mutt to send email from Google Apps gmail account

This illustrates how to setup mutt so that it sends email from a Google Apps gmail account. Alternately, you can just use a Gmail regular account.

First install mutt:
On Debian:
apt-get install mutt

Now, create a folder for mutt:
mkdir -p /.mutt/cache

Now, edit ~/.muttrc file (it may not exist):
emacs ~/.muttrc

It should have the following contents:

account-hook imap://gmail/ “set
set from = "[email protected]"
set realname = "Server Mailer"
set imap_user = "[email protected]"
set imap_pass = "Be4!testpass"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set smtp_url = "smtp:[email protected]@smtp.gmail.com:587/"
set smtp_pass = "Be4!testpass"
set move = no
set imap_keepalive = 900

In the above example mutt configuration file, I had already created a Google Apps Mail account [email protected], with the password “Be4!testpass”. Of course you should set a more complex password.

Create a test message:

emacs /tmp/message.txt
TResting
Pot
Got

Now try sending a mail to yourself to test:
mutt -s “Test from mutt” [email protected] < /tmp/message.txt If you get the following error message: "SASL authentication failed, Could not send the message.", it means that there is a problem with the username or password. If it works, you should momentarily receive an email at the target email account that you specified. This is extremely useful, since it allows you to avoid installing a mail server on your VPS.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Setting up OpenVZ and the OpenVZ Web panel on Debian

First, you’d need to install Debian on your server. For DelimiterVPS, go to https://clients.delimitervps.com/clientarea.php, and login to your account.
Choose the Reinstall server option.
Under ‘Installation Profile’, choose ‘Debian Wheezy’.
Choose a good enough root password. From personal experience, I’d avoid special characters in my root password. I had setup a very complex password once, and found that it was not accepted by the ssh login shell. It’s likely that WHMCS does not escape special characters very well.
Choose ‘Provision Server (Warning)’.

At this point, go back to the email you received from DelimiterVPS, and read the part about KVM/ILO Configuration. You can login to ILO and watch the installation progress. Once installation is done, Proxmox is supposed to be up and running at https://yourip::8006. However we need a couple of steps and a reboot before we can use it.

Run the following:

cat << EOF > /etc/apt/sources.list.d/openvz-rhel6.list
deb http://download.openvz.org/debian wheezy main
EOF
wget http://ftp.openvz.org/debian/archive.key
apt-key add archive.key
apt-get update

Install OpenVZ kernel:

apt-get install linux-image-openvz-amd64

First, you have to remove the default Linux kernel, and set the OpenVZ kernel to start at boot.
Run the following from the shell:

apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64 linux-base
update-grub

You’ll notice that openvz based kernels have now been added to grub (the bootloader).

Enable IP forwarding and other rules are setup:
Edit the file /etc/sysctl.conf, and uncomment/add (Remove the # at the beginning) the following lines:

# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

# Enables source route verification
net.ipv4.conf.all.rp_filter = 1

# Enables the magic-sysrq key
kernel.sysrq = 1

# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

run the following:

sysctl -p
apt-get install vzctl vzquota ploop vzstats

Now, restart the server.

reboot

Run the following:

wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

After some time the installation may stop with the following message:
Fatal error: Panel requires Ruby 1.8 (Ruby 1.9 is not supported).

Run:

update-alternatives --config ruby
# update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/ruby1.9.1   51        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
  2            /usr/bin/ruby1.9.1   51        manual mode

Press enter to keep the current choice[*], or type selection number: 1

Now rerun the installation:

wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

At the end, you will get the message:

Panel should be available at:
http://x.droidzone.in:3000
Default credentials: admin/admin

Now login, and change the default password.

You can now install OpenVZ templates(Physical servers>Localhost>OS Templates>Install new OS Template).
Assign ips to the pool (Ip Addresses>Create new IP pool). Add the IPs assigned to you. You may need to buy more from your provider.

To create a VPS:
Localhost>Virtual servers list>Create virtual server

Creating a custom template.
Provision a VPS using a default template.
Login to the VPS, setup everything including resolvconf, tzdata, locales, dialog, .bashrc etc.

vzctl stop 1
vzctl set 1 --ipdel all --save
cd /var/lib/vz/private/1
tar --numeric-owner -czf /var/lib/vz/template/cache/debian-7.0-x86_64-minimal-custom.tar.gz .

Change default port and enable SSL on Openvz web panel:
Change the following in /etc/owp.conf:

# web server port
PORT=3000

to

PORT=2096

and

# SSL support, on - enable, off - disable
SSL=off

to

SSL=on

Restart the service. Now it is accessible at https://yourdomain.com:2096

I chose 2096 because it is one of the ports that Cloudflare supports and thus you get a free SSL support with Cloudflare.

Create a symlink to /vz because most of the vz tools expects the OpenVZ folders to reside there. This step is not necessary, but can eliminate further problems when other vz related components are installed.

ln -s /var/lib/vz /vz

You also probably need to change:

#NEIGHBOUR_DEVS="detect"

to

NEIGHBOUR_DEVS="all"

at /etc/vz/vz.conf

and do a

service vz restart

For Reference, my network config on node is as below:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 157.266.186.60
        netmask 255.255.255.192
        network 157.266.186.0
        broadcast 157.266.186.63
        gateway 157.266.186.62
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8
        dns-search droidzone.in

And my two addon ips are:

157.266.187.162/32
157.266.187.163/32

Obviously the ips have been scrambled.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Setting up Virtual private servers via Proxmox on a ‘DelimiterVPS’ dedicated server

DelimiterVPS had a nice offer for a value-for-money Dedicated server, the other day. I pounced on my chance to add another dedicated server to my collection. The other one is an Online.net Euro 5.99 server that I have been using for the past year. The server provisioning was quick (within two hours of payment). I paid via Paypal.

Now about setting up the server for creating VPSes..

First, go to https://clients.delimitervps.com/clientarea.php, and login to your account.
Choose the Reinstall server option.
Under ‘Installation Profile’, choose ‘Proxmox VE 3.0’.
Choose a good enough root password. From personal experience, I’d avoid special characters in my root password. I had setup a very complex password once, and found that it was not accepted by the ssh login shell. It’s likely that WHMCS does not escape special characters very well.
Choose ‘Provision Server (Warning)’.

At this point, go back to the email you received from DelimiterVPS, and read the part about KVM/ILO Configuration. You can login to ILO and watch the installation progress. Once installation is done, Proxmox is supposed to be up and running at https://yourip::8006. However we need a couple of steps and a reboot before we can use it.

First, you have to remove the default Linux kernel, and set the OpenVZ kernel to start at boot.
Run the following from the shell:

apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64 linux-base
update-grub

You’ll notice that openvz based kernels have now been added to grub (the bootloader).

If you’d prefer a login screen with Cloudflare SSL, you’d want to change the default Proxmox web panel port from 8006 to 2053, 2083, 2087, 2096, or 8443. (See https://support.cloudflare.com/hc/en-us/articles/200169156-Which-ports-will-CloudFlare-work-with-)

Do this:

sed -i 's/port => 8006/port => 2096/' /usr/bin/pveproxy
service pveproxy restart

Enable IP forwarding is setup:
Edit the file /etc/sysctl.conf, and uncomment (Remove the # at the beginning) the following line:

#net.ipv4.ip_forward=1

You can just run the following:

sed -i "s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g" /etc/sysctl.conf
sysctl -p

Now, restart the server.

You can now login to Proxmox at:

https://yourdomainname.com:2096 (If you changed the IP for Cloudflare DNS),

or

https://yourip:8006 (Default Proxmox login URL).

Choose your server’s root password with Linux PAM authentication.

Before creating VPSes, you need to download OpenVZ templates to the server.
Click on server, and ‘local(server)’ under ‘server’.
Click on the tab ‘Content’
Click on Templates,
Under Section:system, choose to download templates you require.

Now to create a new VPS, Click on ‘Create CT’, enter the following:
Node and VM ID should be automatically populated.
Enter hostname for your VPS: test1.mydomain.com
Password: Choose a complex password
Confirm Password.

Click on Next.
Choose a template from the dropdown.
Click on Next.
Now, choose values for Memory, Swap, Disk size, CPU.
Click on Next.
Choose routed mode, enter one of the ‘additional ip addresses’ you purchased from DelimiterVPS.
Click on Next.
Click on Next again.
Click on Finish.

Your virtual server is now ready. Try logging to it via ssh.

To remove the Proxmox ‘You do not have a valid subscription nag popup’, run the following:

cp /usr/share/pve-manager/ext4/pvemanagerlib.js /usr/share/pve-manager/ext4/pvemanagerlib.bak.js
sed -i "s/data.status !== 'Active'/false/" /usr/share/pve-manager/ext4/pvemanagerlib.js

Credits:
MarkTurner at Lowendtalk for help with server settings


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Install YOURLS URL shortener on your own server

Requirements:
Shared server/VPS with the following installed:
A webserver with php installed
mysql

Set up YOURLS url shortening service on your domain.
I’ve added the domain to i-mscp to create a web hosting directory

ssh to the shell

cd /var/www/virtual/mysite.com/htdocs
rm -rf ./*
git clone https://github.com/YOURLS/YOURLS
mv YOURLS/* ./
rm -rf YOURLS
cp user/config-sample.php user/config.php

Login to phpmyadmin and create a new database named yourlsdb.
Under Privileges tab, create a new user, name it yoursusr
Generate a secure password like this: [email protected]&Cc^95gMY#6Bhd
Tick the box to Grant all privileges on ‘yourlsdb’ to yoursusr

Now edit the config file, and add database details:

emacs user/config.php

Visit http://yourls.org/cookie and generate a cookie key and update it in this same file.

Add appopriate passwords at this block:

$yourls_user_passwords = array(
        'username' => 'password',

Now point the browser to http://yoursite.com/admin/ and click on ‘INSTALL YOURLS’.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to get a VPS’s stats from bash command line using SolusVM Client API

The basic command is of this form:

#curl --data "key=$KEY&hash=$HASH&action=info&ipaddr=true&mem=true&hdd=true&bw=true" $SERVERURL/api/client/command.php

This returns data of the form:

<ipaddr>134.120.43.52,2602:fff8:100:2::6ff4:6b5a</ipaddr><hdd>7516192768,325312512,7190880256,4</hdd><bw>268435456000,115806842,268319649158,0</bw><mem>134217728,47583232,86634496,35</mem><status>success</status><statusmsg></statusmsg><hostname>master.dnsmagic.org</hostname><ipaddress>134.120.43.51</ipaddress><vmstat></vmstat>

In script form:
First define variables:

KEY="LNAQP-ZEWDZ-3EKFR"
HASH="076dffc30f43cc3a134666a04afba78932212b3323e"
ACTION="info&ipaddr=true&mem=true&hdd=true&bw=true"
URL="https://manage.cloud.com"

Then execute it from bash:

curl --data "key=$KEY&hash=$HASH&action=$ACTION" "$URL/api/client/command.php"

Shutdown:

ACTION="shutdown"

View the Complete documentation here.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

X11 forwarding request failed on channel 0

While trying to use the program `gnuplot` on my VPS, I encountered this error:

Failed to initialize wxWidgets.
warning: Too many axis ticks requested (>8)

To fix this, I tried the -X parameter:

[email protected]:~$ ssh -X [email protected]
X11 forwarding request failed on channel 0
Last login:

I checked the server side file /etc/ssh/sshd_config:

[[email protected]] ~ #grep -in --color X11Forwarding /etc/ssh/sshd_config
62:X11Forwarding yes

So that wasnt an issue.

I needed to install the package `xauth` on the server side.

apt-get install xauth

Now, retrying:

[email protected]:~$ ssh -X [email protected]
Last login: Fri Jul  5 21:01:30 2013 from 106.66.117.168
/usr/bin/xauth:  creating new authority file /root/.Xauthority

Welcome to dragon, root!

It worked.
Reference: StackExchange


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.