nginx配置https
https需要的证书我们已经申请到了,下面分享下nginx配置https的一些配置参数!
这是我的配置
server {
listen 443 ssl;
ssl on;
ssl_certificate /etc/letsencrypt/live/zhanj163.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/zhanj163.com/privkey.pem;
server_name go.zhanj163.com;
root /alidata/www/go_workspace/src/go_zhanj163;
index index.html index.htm;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf) {
expires 30d;
}
location ~ .*\.(js|css)? {
expires 12h;
}
location /(css|js|fonts|img)/ {
access_log off;
expires 1d;
root "/alidata/www/go_workspace/src/go_zhanj163";
try_files $uri @backend;
}
location / {
try_files /_not_exists_ @backend;
}
location @backend {
proxy_pass_header Server;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8080;
}
access_log /alidata/log/nginx/access/go.zhanj163.com;
}
===================================================================
如果想启用https同时也想启用http,我们可以这样配置
nginx强制使用https
为了数据安全,我们可以设置强制使用https!
我配置的相对简单,不影响使用,就是一个指向配置!
https://www.linuxidc.com/Linux/2017-12/149764.htm
https://github.com/certbot/certbot