Tuning the Linux kernel for better shadowsocks network throughput

add these lines to /etc/sysctl.conf :

# max open files
fs.file-max = 51200
# max read buffer
net.core.rmem_max = 67108864
# max write buffer
net.core.wmem_max = 67108864
# default read buffer
net.core.rmem_default = 65536
# default write buffer
net.core.wmem_default = 65536
# max processor input queue
net.core.netdev_max_backlog = 250000
# max backlog
net.core.somaxconn = 4096
# resist SYN flood attacks
net.ipv4.tcp_syncookies = 1
# reuse timewait sockets when safe
net.ipv4.tcp_tw_reuse = 1
# turn off fast timewait sockets recycling
# net.ipv4.tcp_tw_recycle = 0
# short FIN timeout
net.ipv4.tcp_fin_timeout = 30
# short keepalive time
net.ipv4.tcp_keepalive_time = 1200
# outbound port range
net.ipv4.ip_local_port_range = 10000 65000
# max SYN backlog
net.ipv4.tcp_max_syn_backlog = 8192
# max timewait sockets held by system simultaneously
net.ipv4.tcp_max_tw_buckets = 5000
# turn on TCP Fast Open on both client and server side
net.ipv4.tcp_fastopen = 3
# TCP receive buffer
net.ipv4.tcp_rmem = 4096 87380 67108864
# TCP write buffer
net.ipv4.tcp_wmem = 4096 65536 67108864
# turn on path MTU discovery
net.ipv4.tcp_mtu_probing = 1

net.ipv4.tcp_timestamps=1
net.ipv4.ip_no_pmtu_disc = 1
net.ipv4.tcp_mem = 25600 51200 102400
net.ipv4.ip_default_ttl=129
sysctl -p /etc/sysctl.conf

References
https://shadowsocks.org/en/config/advanced.html
https://linode.com/docs/networking/vpn/create-a-socks5-proxy-server-with-shadowsocks-on-ubuntu-and-centos7/
https://maxlv.net/optimize-a-shadowsocks-server/

Tuning the Linux kernel for better network throughput

add these lines to /etc/sysctl.conf :

fs.file-max = 100000
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_syncookies = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.rmem_default=65536
net.core.wmem_default=65536
net.ipv4.route.flush=1

and then :

sysctl -p /etc/sysctl.conf

References
http://www.techrepublic.com/blog/linux-and-open-source/tuning-the-linux-kernel-for-more-aggressive-network-throughput/
https://wwwx.cs.unc.edu/~sparkst/howto/network_tuning.php
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Web_Platform/5/html/Administration_And_Configuration_Guide/jgroups-perf-udpbuffer.html
http://www.nateware.com/linux-network-tuning-for-2013.html
http://www.slashroot.in/linux-network-tcp-performance-tuning-sysctl

Enable linux swap partition

You have no configuration for swap in /etc/fstab . Add following line to that file:

UUID=<uuid> none   swap    sw    0       0   

You have to replace with the uuid of your swap partition. To do that, run sudo blkid

$ sudo blkid
/dev/sda1: LABEL="System Reserved" UUID="88A0D0A1A0D09752" TYPE="ntfs" 
/dev/sda2: UUID="0620D9F920D9EFA3" TYPE="ntfs" 
/dev/sda5: UUID="c282b418-2045-4852-8789-88a44360a0bb" TYPE="ext4" 
/dev/sda6: UUID="f99c6a0c-790a-45ca-a1a9-8874f5a2999b" TYPE="ext4" 
/dev/sda7: UUID="4cc2e909-ebd1-4c72-abee-aa32035bf330" TYPE="swap"

References
http://askubuntu.com/questions/194775/swap-not-available-i-must-manually-swapon-after-every-reboot

Configure Let’s Encrypt for Apache on Ubuntu

sudo apt-get install python-letsencrypt-apache 
letsencrypt --apache
nano /etc/apache2/apache2.conf
<VirtualHost *:443>
	SSLEngine on
	SSLCertificateKeyFile /etc/letsencrypt/live/dl.mhdr.ir/privkey.pem
	SSLCertificateFile /etc/letsencrypt/live/dl.mhdr.ir/cert.pem
	SSLCertificateChainFile /etc/letsencrypt/live/dl.mhdr.ir/chain.pem
    DocumentRoot "/var/www/html/dl"
    ServerName dl.mhdr.ir
</VirtualHost>
service apache2 restart

PPA

$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-apache

note : only the last VitualHost will be detected by letsencrypt
References
https://certbot.eff.org/#ubuntuxenial-apache
https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
https://letsencrypt.org/