首页 > 系统相关 >nginx环境下配置https域名你知道吗?

nginx环境下配置https域名你知道吗?

时间:2022-08-15 15:36:43浏览次数:118  
标签:https http log nginx 域名 proxy conf include

拿到的证书分两个文件,一个是xxx.crt,一个是xxx.key,分别对应公钥和私钥。

1.假设我们的nginx安装目录是:/etc/nginx/,在目录下创建一个新目录,姑且命名为cert,把两个证书文件扔到此目录下。
2.编辑conf目录下的nginx.conf文件

For more information on configuration, see:

* Official English Documentation: http://nginx.org/en/docs/

* Official Russian Documentation: http://nginx.org/ru/docs/

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

Load dynamic modules. See /usr/share/nginx/README.dynamic.

include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ remoteu​ser[time_local] “KaTeX parse error: Double superscript at position 34: … '̲status b o d y b y t e s s e n t " body_bytes_sent " bodyb​ytess​ent"http_referer” ’
‘“ h t t p u s e r a g e n t " " http_user_agent" " httpu​sera​gent""http_x_forwarded_for”’;

access_log  /var/log/nginx/access.log  main;

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen       80;
server_name  域名;
 rewrite ^(.*) https://域名/$1 permanent;
 charset UTF-8;
location / {
   root /root/www/; # 这个是指定一个项目所在目录
  index  index.html index.htm;  # 这个是指定首页的文件名
   proxy_redirect off;
   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection "upgrade";
  }
}
更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/120182264

标签:https,http,log,nginx,域名,proxy,conf,include
From: https://www.cnblogs.com/wangchuanxinshi/p/16588459.html

相关文章

  • http和https的概念 和 区别
    1、http和https的基本概念http http是客户端和服务端传输请求应答的标准,用与从www服务器传输超文本到本地浏览器的超文本传输协议。httpshttps是以安全为目的的ht......
  • 4、编译安装nginx,实现多域名 https
    4、编译安装nginx,实现多域名https 一、编译安装nginx1.源码包下载https://nginx.org/en/download.html2.编译安装[root@CentOS8~]#yum-yinstallgccpcre-devel......
  • 2. 使用rewrite规则实现将所有到a域名的访问rewrite到b域名
    2. 使用rewrite规则实现将所有到a域名的访问rewrite到b域名a域名:www.magedu.orgb域名:m.magedu.org a域名配置:  #将a域名的所有的连接都临时跳转到b域名 server......
  • nginx 一些简单访问控制模块
    nginx已经内置了一些简单的访问控制模块,利用好这些模块我们可以提升系统的安全几个比较有用的标准模块基本都是利用了access阶段的能力limit_except限制请求方法的(......
  • Nginx学习笔记
    Nginx简介Nginx(enginex)是一个高性能的HTTP和反向代理web服务器,Nginx和Apache的区别Apache和Nginx最核心的区别在于apache是同步多进程模型,一个连接对应一个进程;......
  • 【Linux】yum源安装nginx服务
    前言centos通过yum命令安装nginx服务,并开放监听端口、设置开机自启等1、配置yum源并进行安装如有其他版本需求的,可以跳转官网nginx:Linuxpackages,选取适合自......
  • Linux 域名和DNS
    名字解析的作用:TCP/IP网络中,设备之间的通信依赖IP地址来实现,但是IP地址不好记忆,所以就将每一台设备用一个名字来进行标识,但是这个名字计算机不能解析。所以就需要借助名字......
  • 【问题解决】解决使用aliyuncdn加速的域名证书不同步问题
    今天登录上博客发现好家伙资源链全挂了,进去一看发现是证书到期了,但是我回服务器查看证书发现证书已经更新而且是有效状态,清缓存一类的都尝试过了,依旧不行,然后网上找到了一......
  • flask+uwsgi+nginx 搭建后端服务器
    1)构建flask服务安装创建虚拟环境安装flask##创建虚拟环境python3-mvenvvenv#安装flaskpipinstall--upgradepippipinstall-Usetuptoolspipinstal......
  • HTTPS的实现原理 ---- 核心 SSL/TLS协议
    是在应用层和传输层之间添加的安全层(SSL/TLS协议)端口号:HTTP默认是80,HTTPS默认是443。URL前缀:HTTP的URL前缀是http://,HTTPS的URL前缀是https://。......