六月 7th, 2018

首先,你得有台云主机Vps。国内的话有阿里云、腾讯云这些。由于一些不可描述的原因,我选择的是部署在香港的 VPS,懂的都懂,其实我这台 VPS 主要是服务于 SS。当然一台买了这个 VPS 只拿来做 SS 服务有点浪费啊,而且部署在 github page 上的静态博客访问其实挺慢的,然后因为不想备案的原因,还无法用到国内大厂的 CDN 加速服务,于是萌生了干脆把博客静态指向到 VPS 的 IP 算了。

然后你还得买个域名,这总不能用 IP 来访问吧,太low。

安装 Nginx

在这里就不累赘了

配置 Nginx

配置文件在 /etc/nginx/nginx.conf

其中配置了两个 server,一个 80 端口的是 HTTP,一个 443 端口的是 HTTPS,这里强制让 80 端口重定向到了 HTTPS。

user root;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable “msie6”;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
#include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
server {
listen 80;
server_name www.anany.vip anany.vip;
return 301 https://$server_name$request_uri;
}
server{
server_name www.anany.vip anany.vip;
listen 443;
location / {
root /root/blog/pages;
index index.html;
}
ssl on;
ssl_certificate /etc/nginx/anany.vip_bundle.crt;
ssl_certificate_key /etc/nginx/anany.vip.key;
}
}

Comments are closed.