centos nginx https 配置
1,如果想配置一个域名到指定目录咋弄呢?下面这个
server {
listen ;
server_name 这里换成你的域名,例如baidu.com;
set $root_path '/home/wwwroot/tapai_html/';
root $root_path;
index index.html index.php index.htm;
# rewrite ^(.*) https://$server_name;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:;
fastcgi_index /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# location /imgtext_detail {
# proxy_pass /home/wwwroot/tapai_html/imgtext_detail;
# proxy_pass http://127.0.0.1:9000/imgtext_detail/;
# }
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
2,如果想让这个域名同时也支持https访问,该咋办呢?下面这个server和上面的server同时在就好了
server {
listen ;
listen [::]:;
server_name 这里换成你的域名,例如baidu.com;
root /home/wwwroot/tapai_html/;
ssl on;
# ssl_session_tickets off;
ssl_certificate "/etc/nginx/ssl/这里换成证书.crt"; #也有可能是.pem结尾的
ssl_certificate_key "/etc/nginx/ssl/这里换成秘钥.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
3,如果想让同个ip,支持两个https域名,该咋办呢?把上面server复制一份,把里面的server_name 换成另一个域名,并且把证书和秘钥路径改一下就行了
server {
listen ;
listen [::]:;
server_name 这里配置另一个域名,比如qq.com;
root /home/wwwroot/tapai_html/;
ssl on;
# ssl_session_tickets off;
ssl_certificate "/etc/nginx/ssl/这里换成此域名对应的证书.pem";
ssl_certificate_key "/etc/nginx/ssl/这里换成此域名对应的秘钥.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
centos nginx https 配置的更多相关文章
- nginx https 配置样例
站点nginx https 配置模板 第一章 nginx 支持https 配置样例 其他 相关链接地址 第一章 nginx 支持https 配置样例 说明:https 段配置参数说明 Server 段 ...
- nginx https配置后无法访问,可能防火墙在捣鬼
同事发现nginx配置后https 无法访问,我帮忙解决的时候从以下出发点 1.防火墙未开放443端口 2.配置出错 1 2 3 于是就 netstat -anp 查看防火墙开的端口 发现已经在监听了 ...
- Nginx Https配置不带www跳转www
把 morethink.cn和www.morethink.cn合并到一个server上去,使用301永久重定向. 然后将 https://morethink.cn 转到 https://www.mor ...
- Ubuntu Nginx https 配置
#配置http跳转到https 80跳转443server { listen ; server_name www.***.com www.***.cn; https://$server_name$re ...
- ingress nginx https配置
3.https配置第一步:制作自签证书 [root@master demo]# openssl genrsa -out tls.key 2048 [root@master demo]# openssl ...
- centos nginx server_name 配置域名访问规则
今天配置Server_name时,希望禁用一些域名,应为这些域名我想让通过另外一个Server配置 server_name "~^((\w*[^w]{1}\w*)|w{1,2})\.hell ...
- nginx https配置
nginx的https服务配置如下(在server中配置): ssl on; ssl_session_cache shared:SSL:50m; ssl_session_timeout 1d; ssl ...
- centos+nginx从零开始配置负载均衡
nginx负载均衡的理解 nginx是一个轻量级的.高性能的webserver,他主要可以干下面两件事: 作为http服务器(和apache的效果一样) 作为反向代理服务器实现负载均衡 现在nginx ...
- nginx https 配置
1.创建证书并下载(下载完成后有两个文件) *.pem *.key 2.将两个文件放在linux 某个目录下 3.配置nginx的conf配置文件 server{ # https 端口默认不是80,是 ...
随机推荐
- vue data中的对象的属性如何使用watch监听
在写项目的时候遇到了一个问题,就是需要动态监听data中一个对象的属性的变化.遇到了许多坑,在此过程中也发现了两种解决方案. 一.通过deep属性实现 data() { return { parent ...
- Leetcode之101. Symmetric Tree Easy
Leetcode 101. Symmetric Tree Easy Given a binary tree, check whether it is a mirror of itself (ie, s ...
- JAVA实验报告及第八周总结
JAVA第八周作业 实验报告六 实验一 编写一个类,在其main()方法中创建一个一维数组,在try字句中访问数组元素,使其产生ArrayIndexOutOfBoundsException异常.在ca ...
- poj3162(树形dp+线段树求最大最小值)
题目链接:https://vjudge.net/problem/POJ-3162 题意:给一棵树,求每个结点的树上最远距离,记为a[i],然后求最大区间[l,r]满足区间内的max(a[i])-min ...
- [转帖]Grafana背后的Nginx和Apache Proxy
Grafana背后的Nginx和Apache Proxy https://ywnz.com/linuxyffq/5590.html 这个网站貌似非常非常好 在本文中,我将向你展示如何在Nginx和Ap ...
- Hadoop集群搭建-02安装配置Zookeeper
Hadoop集群搭建-05安装配置YARN Hadoop集群搭建-04安装配置HDFS Hadoop集群搭建-03编译安装hadoop Hadoop集群搭建-02安装配置Zookeeper Hado ...
- CSS:盒子的定位与浮动
CSS--盒子定位.浮动与居中 HTML中的每个元素都是一个盒子 浏览器对HTML文档进行解析,根据盒子的属性对其进行排列. 每个元素默认使用标准文档流定位 标准文档流:是指浏览器读取HTML ...
- php双向队列的实现
队列是一种线性表,按照先进先出的原则进行 单向队列:只能从头进,从尾出 双向队列:头尾都可以进出 class DuiLie { private $array = array();//声 ...
- 图解django的生命周期
其实django的生命周期的大体框架就是这样,剩下的细致的,自己再补充! 图片实在是有点抽象! 谅解!! koala-----给你更多技术小干货
- spark教程(八)-SparkSession
spark 有三大引擎,spark core.sparkSQL.sparkStreaming, spark core 的关键抽象是 SparkContext.RDD: SparkSQL 的关键抽象是 ...