What's new

Closed Sariling proxy/ssh/openvpn/shadowsocks server tutorial - part 2

Status
Not open for further replies.

tekninja

Honorary Poster
Joined
Apr 6, 2017
Posts
287
Reaction
885
Points
213
WARNING: This is an Advanced Tutorial. Pabababawin ko as much as possible pero kung dumudugo na talaga ilong mo, andyan si bestfriend google, magpatulong ka. Kung malakas ang loob mong matuto, bilib ako sayo, keep on reading.

UPDATE: My tutorial primarily used VULTR servers (mas madali kasi dun maka free trial) na sa ngayun ay minsan may problem sa accuracy ng bandwidth usage. Kung maencounter mo ito, contact nyo ang support team nila. If it persists, go with DigitalOcean, though need mo ng Credit Card para maka-create ng VPS.

Advanced Tutorials for kaPHC Series
Paano Magkaroon ng Sariling Proxy/SSH/OpenVPN,Shadowsocks Server?

Links muna tayo para sa kararating lang:

Part 1 – Kailangan mo ng VPS (Virtual Private Server)
https://phcorner.net/t/sariling-proxy-ssh-openvpn-shadowsocks-server-tutorial.375615/

Part 2 – Magsimulang mag-install ng Services sa VPS

Q&A

1. Ano ang Services?

a. Ito ay programs na ii-install mo sa server, and since hindi ito on-demand lang pagaganahin at expected na laging available, ito ay usually umaandar sa background.

b. Examples nito na familiar sa mga kaPHC ay Proxy, SSH, OpenVPN, at ShadowSocks. And yes, LAMP and MySQL ay services din para sa mga web developer dyan.

2. Ano ang mga kilangan i-consider sa paggawa ng Services?

Note: Pagbigyan nyo ako na mag-off-topic ng konti para may dagdag background narin.

a. Command Line. Ihanda mo na ang sarili mo sa paggamit ng command line. Grow up and take it as a challenge. Kung nandito ka at nagbabasa, it means ayaw mo na maging newbie. So kung disidido ka talaga matuto, bilib ako sayo, basa lang!

b. Config Files. Walang iiyak ha, haha! Kasi almost all options and configurations ay nasa file na ie-edit mo. Wag ka maghanap ng click mo lang checkbox ok na. Search mo kay google or YøùTùbé ang “Nano Editor” para may konting heads-up kana.

c. Linux Distro at Version. Bawat klase ng linux ay may ibaibang “Package Manager” (o software na nagma-manage ng installation.) Meaning may commands na hindi gagana sa ibang distro. Sa versions naman, kahit parehas na distro pa yan, pag malaki na ang difference sa version number (ex. 6.2 vs 7.0) ibang iba narin ang core nyan. Malimit iba na commands sa firewall, networking, etc. So be aware. Pero wag matakot, basa basa lang sa net.

d. Software Versions. Maraming tutorials sa internet, pero tandaan natin na ibaiba ang versions sa bawat tutorial. Make sure pareho sa ininstall mo. Minsan din ang features na hinahanap natin nasa specific version pala. So always check.

e. Ports. Get a good knowledge about sa usual ports (ex. http = 80, https = 443, ftp = 21, ssh = 22, proxy = 3128, etc. Ask nyo google for more infos.) Ano connect nito? Well, kung gagawa ka ng Proxy Service tapos patatakbuhin mo sa port 80 or 443, tapos nag-install ka ng Web Service, eh gumagawa ka ng sakit sa ulo, magko-conflict syempre. Or gumawa ka ng Proxy Service tapos padadaanan mo ng SSH, eh wala naman sa proxy config na naglagay ka ng port 22, iyak ka ngayun sa 403 response.

f. Firewalls. Since ang services natin ay naa-access natin through ports, be aware na may tinatawag na firewall. Ito ang either nagba-block, nag ra-route, nagma-mask or nag-aallow.

g. Konting wrap-up lang po. Malaking tulong na may idea ka sa mga ito to help you troubleshoot. So kung hindi gumana ang service, (1) first suspect, naka allow ba sa firewall ang port? (2) nakaset ba sa config file yung iniexpect mo na port? (3) umaandar ba ang service? (4) wala bang ibang gumagamit ng port? Yan po ay extended helps. The rest is up to your beautiful brain, kaya mo yan.


EXTENDED PART
Ito ay para hindi ka lang mabitin dahil meron din tayong separate Thread para sa paggawa ng services. See the end of this Post for details.

Paano gumawa ng services? Yehey!


Isaisahin na natin. Unahin muna natin yung service na magagamit mo agad and so on.

PROXY SERVER

1. Ano ang Proxy Server? From the word “proxy” (parang ninong mo sa kasal na hindi nakarating, hahaha! Hanap ka ngayun ng proxy. Haha!) So instead na ikaw ang nakikita ng mga webservers na nagrerequest ng website, yung IP ng Proxy Server ang nakikita nila.

2. Kapag nagconnect ka sa Proxy, nagcre-create ito ng direct tunnel between your server and your device. Kaya nga kung nasaan ang server mo dun nagrerespond si google (ex. akala ni google nasa Singapore ka kaya google.com.sg binibigay nya sayo na website)

3. Tama na to, let’s have fun na! Buksan na ang MobaXterm! Connect na po tayo sa server as detailed in PART 1. (Tignan nyo number of failed logins sa screenshot ko, kagagawa ko palang may mga nagbu-bruteforce na, welcome to the real world! Haha!)

3a3.jpg

4. First command po natin ay: (hindi po kasama yung pound or sharp sign na “#”)
=====================
# yum -y install squid
=====================

3a4.jpg

3a4a.jpg

“Yum” ang name ng Package Manager natin, then yung “-y” ay yes in advanced sa mga itatanong nya. Then “squid” ang pangalan ng software natin (Squid Proxy Server). Cut and paste lang sa MobaXterm, then hit enter.

5. Then cut and paste:
=====================
# systemctl enable squid.service
=====================

Hit enter ulit. Normal lang na walang response kundi next line sa command tulad ng nasa screenshot. It means successful. Si “systemctl” yan ang nagmamanage ng services, “enable squid.service” means aandar na Proxy natin sa background and will automatically run kapag nagboot.

3a5.jpg

6. Time to edit the config file:
=====================
# nano /etc/squid/squid.conf
=====================

Cut, paste and hit enter. Then welcome sa Nano Editor. Use keyboard arrows to navigate.

First things first, make sure lahat ng padadaanin ninyo sa Proxy nakalist sa ports nya na iaallow. So if magpapadaan kayo ng SSH, idagdag nyo ang port 22 both sa “Safe_ports” at “SSL_ports”. This rule applies to all services na gusto ninyo padaanin.

3a6a.jpg

Tulad sa screenshot ko, ito idadagdag natin:
---------------------------------------------
acl Safe_ports port 22
acl SSL_ports port 22
---------------------------------------------

Para magamit natin ang proxy publicly. Scroll down tayo hanggang mahanap yung “http_access deny all” palitan natin ng:
---------------------------------------------
http_access allow all
---------------------------------------------

3a6b.jpg

Then para maisave natin hit natin keyboard combo na “CTRL + X” then may lalabas na question, pakisagot ng “Y”, then hit “enter”.

3a6c.jpg

7. Setup natin ang firewall,
=====================
# firewall-cmd --zone=public --add-service=squid --permanent
=====================

Then reload natin,
=====================
# firewall-cmd --reload
=====================

Then restart natin si Squid Proxy,
=====================
# systemctl restart squid
=====================


8. Dito palang success na tayo! :) Try mo itest. Open browser sa - You do not have permission to view the full content of this post. Log in or register now.

Ilagay ang IP address ng VPS mo then port 3128.

3a8.jpg

Wow! Sarap maka-hunt ng ganyang proxy ano? Green lahat... Tsk! Hahaha! Mas másáráp pag ikaw mismo gumawa! :)

9. Pero alam ko na ayaw mo naman na lahat ng tao pwede gamitin ang proxy mo diba? (pero ikaw, galing mo maghunt ng free proxy, hahaha!). So let’s go further and create a username and password.

Install tayo ng authenticator tools
=====================
# yum -y install httpd-tools
=====================

Then prep natin yung file,
=====================
# touch /etc/squid/passwd && chown squid /etc/squid/passwd
=====================

Then create tayo ng USER na for example “kaphcuser”, ito yung akin “htpasswd -m /etc/squid/passwd kaphcuser”, yung sa iyo na username ipalit mo sa code,
=====================
# htpasswd -m /etc/squid/passwd [username]
=====================

Magtatanong yan ng password, lagyan mo

3a9a.jpg

Then itest natin kung tama ginawa natin,
=====================
# /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
=====================

Maghinintay yan ng input, type mo username na ginawa mo, then space then password. Sa sample na ginawako parehas ang username at password (sample lang ito ha) kaya ito inilagay ko “kaphcuser kaphcuser” then enter.

May lalabas dyan na OK if successful. Then hit keyboard combo na CTRL+C to exit checking.

3a9b.jpg

Hindi pa tapos, one last edit para magrequire si squid ng password. Balik edit tayo:
=====================
# nano /etc/squid/squid.conf
=====================

Then simple lang, ilagay mo lang ito sa dulo ng file
---------------------------------------------
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 2 hours
acl auth_users proxy_auth REQUIRED
http_access allow auth_users
---------------------------------------------

CTRL+X, enter then restart natin ulit si Squid Proxy,
=====================
# systemctl restart squid
=====================

10. What next? Time to use it. Enjoy!

Thank you sa lahat ng nag appreciate mula pa sa unang thread. It's my pleasure to help!


Sa lahat ng naglike, i like you too! Hahaha!

Sa lahat ng nagreply, you inspire me, kaya eto na Complete Series para sa inyo!

PROXY SERVER Tutorial

https://phcorner.net/t/sarili-mong-proxy-server-tutorial-series.376257/

OPENVPN SERVER Tutorial
https://phcorner.net/t/sarili-mong-openvpn-server-tutorial-series.376338/

SSH TUNNELING SERVER Tutorial
https://phcorner.net/t/sarili-mong-ssh-tunneling-server-tutorial-series.376834/#post-5519976

SHADOWSOCKS SERVER Tutorial
https://phcorner.net/t/sarili-mong-shadowsocks-server-tutorial-series.377223/#post-5528773

BONUS EXTENDED SERIES

TORRENT SERVER Tutorial
Soon!
Give me a few weeks... May Big Project lang at the moment.
Para may idea kayo, and to help narin, i-link ko muna yung isa kong thread:
https://phcorner.net/t/download-tayo-ng-torrent-kahit-blocked-ang-port-hiperdown-style.376897/
 

Attachments

Last edited:
permon

if ikaw ang may-ari ng vps account, root ang default account na ibibigay sa iyo. If user ka naman dapat may admin priviledges ka. Lagyan mo lang ng "sudo" before every command. Or gawin mong first command ang "sudo su", kung admin ka hihingi yan ng password, then para ka naring root.
 
kaya pala ayaw ng kaibigan ko maging sudoer ako heheheh...thanks sa info ts abang lang ako sa susunod mong tut...
 
Kaylangan ba may net ang pc ko.para makagawa nyan ts ?

Dito sa Tutorials ko, itinuturo ko kung paano gumawa ng Services sa existing na VPS. So need talaga ng internet. Kung net tricks gagamitin mo, malaki chance na madisconnect during process baka magkaproblem ka.

Kung may existing Linux ka dyan, specially CentOS 7, pwede mo pagpractisan... Gagawa din ako ng Tutorial para dyan in the future. Unahin ko muna ang nakapila sa priority list ko, SSH Tunneling Server then Shadowsocks Server for VPS.
 
Dito sa Tutorials ko, itinuturo ko kung paano gumawa ng Services sa existing na VPS. So need talaga ng internet. Kung net tricks gagamitin mo, malaki chance na madisconnect during process baka magkaproblem ka.

Kung may existing Linux ka dyan, specially CentOS 7, pwede mo pagpractisan... Gagawa din ako ng Tutorial para dyan in the future. Unahin ko muna ang nakapila sa priority list ko, SSH Tunneling Server then Shadowsocks Server for VPS.
Okay thanks ts.. Keep sharing.. Interesado po ako sa mga ganito.
 
Status
Not open for further replies.
Back
Top