## 把自己主页放到nginx上 ## 1. 搭建ecs主机 2. 安装nginx 3. 拷贝主页文件到ecs主机,到nginx的默认路径上 4. 申请域名,购买证书(或者采用cerbot生成免费的证书,cerbot就是Electronic Frontier Foundation (EFF)这个机构给大家发的福利,简单的一句话来说就是给你提供3个月的免费证书,证书到期后继续免费续约) 5. 配置nginx绑定证书 5. 绑定域名到自己的网站 ``` server { listen 443 ssl; server_name xxx.com; #root /usr/share/nginx/html; ssl_certificate /opt/cert/xxx/xxx.com.pem; # managed by Certbot ssl_certificate_key /opt/cert/xxx/xxx.com.key; # managed by Certbot error_log /opt/nginx/logs/xx_error.log error; access_log /opt/nginx/logs/testmallui_access.log;# Load configuration files for the default server block. #include /etc/nginx/default.d/*.conf; location / { # 把host头传过去,后端服务程序将收到your.domain.name, 否则收到的是localhost:8080 proxy_pass http://192.168.0.30:80/; proxy_set_header Host $http_host; # 把cookie的path部分从localhost:8080替换成your.domain.name proxy_cookie_domain 192.168.0.30:80 xxx.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 20m; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } ```