Skip to content

Instantly share code, notes, and snippets.

@davxiao
Last active June 10, 2020 22:24
Show Gist options
  • Save davxiao/c4f16ebbcdb2ec0701bcaad24640d12c to your computer and use it in GitHub Desktop.
Save davxiao/c4f16ebbcdb2ec0701bcaad24640d12c to your computer and use it in GitHub Desktop.
# SSL configuration
#
server {
listen 8964 ssl;
# allowing only local networks and cloudflare CDN IPs for security
allow 127.0.0.0/8;
allow 192.168.2.0/24;
# cloudflare IPs. see https://www.cloudflare.com/ips/
allow 173.245.48.0/20;
allow 103.21.244.0/22;
allow 103.22.200.0/22;
allow 103.31.4.0/22;
allow 141.101.64.0/18;
allow 108.162.192.0/18;
allow 190.93.240.0/20;
allow 188.114.96.0/20;
allow 197.234.240.0/22;
allow 198.41.128.0/17;
allow 162.158.0.0/15;
allow 104.16.0.0/12;
allow 172.64.0.0/13;
allow 131.0.72.0/22;
deny all;
server_name api.davidxiao.me;
ssl_certificate /etc/mycert/cloudflare/origin-cert.pem; # cloudflare self-signed cert only for CDN purposes
ssl_certificate_key /etc/mycert/cloudflare/priv.key; # cloudflare self-signed cert only for CDN purposes
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
location /remark42 {
# rewrite so as to remove /remark42 from the request URL and pass the rest onto the docker
rewrite ^/remark42(/.*)$ $1 break;
proxy_pass http://localhost:8899; #remark42 container mapped to the host poort 8899
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}