Skip to content

Instantly share code, notes, and snippets.

@coder4web
Last active December 27, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coder4web/5792983 to your computer and use it in GitHub Desktop.
Save coder4web/5792983 to your computer and use it in GitHub Desktop.
Essential web-server security
# ------------------------
# SSH:
# ------------------------
#http://wiki.centos.org/HowTos/Network/SecuringSSH
#https://www.linode.com/docs/security/securing-your-server/
sudo nano /etc/ssh/sshd_config
Port 20202
PermitRootLogin no
#PermitRootLogin without-password
# OR (AWS)
# Only allow root to run commands over ssh, no shell
# PermitRootLogin forced-commands-only
UseDNS no
PasswordAuthentication no
AllowUsers avd deployer
#AWS: AllowUsers avd deployer ec2-user
sudo systemctl restart sshd
#sudo service ssh restart
#/etc/init.d/sshd restart
# ------------------------
# FW: FirewallD
# ------------------------
# @see ~/avd-conf/root/sh/srv/setup_fw.sh
firewall-cmd --zone=public --add-service=http
firewall-cmd --zone=public --add-service=https
firewall-cmd --zone=public --add-service=smtp
firewall-cmd --runtime-to-permanent
firewall-cmd --zone=public --permanent --list-service
firewall-cmd --zone=public --list-ports
firewall-cmd --reload
sudo systemctl restart firewalld
# ------------------------
# nginx:
# ------------------------
# https://weakdh.org/sysadmin.html
time openssl dhparam -out /etc/nginx/ssl/dhparams.pem 2048
# nginx.conf:
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
# ------------------------
# PHP:
# ------------------------
expose_php = Off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment