Sunday, July 7, 2019

Build a 'trojan' server

Step 1: 
(a). install nginx
(b). install letsencrypt as previously posted

Step 2:
(a). obtaining a Let's Encrypt SSL certificate
(b). set  'live' and 'archive' folder in 'letsencrypt' to 755 recursively

@ref_github_1

Step 3:
change nginx configuration as follws:
`
server {
    listen 127.0.0.1:80 default_server;

    server_name example.com;

    location / {
        proxy_redirect off; 
        proxy_pass https://www.xxxx.net;
    }

}

server {
    listen 127.0.0.1:80;

    server_name 100.100.100.100; # server IP address

    return 301 https://example.com;
}

server {
    listen 0.0.0.0:80;
    listen [::]:80;

    server_name _;

    return 301 https://example.com;
}
`
@ref_blog.siaimes.me_2

Step 4:
Option 1: Install 'trojan' from github:
@ref_trojan-gfw.github.io_3
(a).
run
 `sudo apt -y install build-essential cmake libboost-system-dev libboost-program-options-dev libssl-dev default-libmysqlclient-dev`
to install all the necessary dependencies.

(b).
`git clone https://github.com/trojan-gfw/trojan.git`
` cd trojan/`

(c).
`mkdir build`
`cd build/`
`cmake ..`
`make`
`ctest`
`make install`

(d).
edit '/usr/local/etc/trojan/config.json'
set "password"
set "cert": "/etc/letsencrypt/live/example.com/fullchain.pem"
set "key": "/etc/letsencrypt/live/example.com/privkey.pem"
set "alpn": [ "http/2.0" ]

(e).
`systemctl restart trojan nginx`
`systemctl status trojan nginx`
`systemctl enable trojan nginx`

Option 2: Install 'trojan' from 'apt repository'
(a).
`
apt install software-properties-common
add-apt-repository ppa:greaterfire/trojan
apt update

apt install trojan
trojan version
vi /etc/trojan/config.json
`
@ref_blog.siaimes.me_4

Step 5:
Firewall:
'
apt install ufw
ufw allow ssh     # Or port number
ufw allow https
ufw allow http
ufw enable
ufw status
ufw status verbose
'
@ref_blog.siaimes.me_5


No comments:

Post a Comment