nginx 多域名指向多个根目录配置,设置自定义请求头 proxy_set_header,ssl 证书安装配置
1.nginx.conf 配置文件引入子配置文件 include vhost-server/*.conf; 关键在 server_name 不同域名执行不同的根
user root;
#user nobody;
worker_processes 1; error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
client_max_body_size 20m;
include mime.types;
default_type application/octet-stream; underscores_in_headers on;
#add_header X-Frame-Options SAMEORIGIN;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/dev_access.log; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; include vhost-server/*.conf;
}
2. vhost-server 下子配置 a.conf b.conf
a.conf
server {
listen 80;
listen 443 ssl;
server_name test.com;
#ssl on;
ssl_certificate cert/test/test.pem;
ssl_certificate_key cert/test/test.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
error_log logs/sitxqy_error.log;
access_log logs/sitxqy_access.log;
autoindex on; # 显示目录
autoindex_exact_size on; # 显示文件大小
autoindex_localtime on; # 显示文件时间
root html/test/;
index index.html;
client_max_body_size 20m;
location /api/ {
proxy_pass http://localhost:88/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|less|map|eot|svg|ttf|woff|woff2|cab|scss|otf|exe|pdf|doc|xlsx)$ {
# root html/xqc-h5/cloudSign;
# index index.html;
# }
location / {
try_files $uri $uri/ /index.html;
}
location /a {
try_files $uri $uri/ /a/index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
index index.html;
}
}
b.conf
server {
listen 80;
listen 443 ssl;
server_name testa.com;
#ssl on;
ssl_certificate cert/testa.pem;
ssl_certificate_key cert/testa.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
error_log logs/sitxqy_error.log;
access_log logs/sitxqy_access.log;
autoindex on; # 显示目录
autoindex_exact_size on; # 显示文件大小
autoindex_localtime on; # 显示文件时间
root html/cloudSignOpen;
index index.html;
client_max_body_size 20m;
location /api/ {
proxy_pass http://localhost:88/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
try_files $uri $uri/ /index.html;
}
location /a {
try_files $uri $uri/ /a/index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
index index.html;
}
}
nginx 多域名指向多个根目录配置,设置自定义请求头 proxy_set_header,ssl 证书安装配置的更多相关文章
- centOS7 apache ssl证书安装配置
背景说明:服务器是centOS7.4 七牛申请的免费ssl证书 默认apache是没有安装SSL模块的,所以需要安装,接着使用命令: yum install -y mod_ssl apache目录 / ...
- nginx ssl证书安装配置
原理图: - 客户端生成一个随机数 random-client,传到服务器端(Say Hello) - 服务器端生成一个随机数 random-server,和着公钥,一起回馈给客户端(I got it ...
- Tomcat SSL证书安装配置
[From Internet] 首先找到安装Tomcat 目录下该文件“Server.xml”,一般默认路径都是在Conf 文件夹中.然后用文本编辑器打开该文件,接着找到 <Connector ...
- 【转】七牛免费SSL证书,配置自定义域名CDN加速
原文链接:https://excaliburhan.com/post/use-qiniu-ssl-and-cdn.html 申请七牛SSL证书 其实,七牛在很早之前就支持CDN使用https,但是他要 ...
- [python][nginx][https] Nginx 服务器 SSL 证书安装部署
目录 前言 1 申请证书 2 Nginx 服务器 SSL 证书安装部署 2.1.准备 Nginx 环境 2.2 证书部署 2.3 Nginx 配置 3 最后 参考链接 前言 博主博客中的图片,使用的是 ...
- centos tomcat/resin安装配置 卸载系统自带的java tomcat安装配置 安装JDK resin安装配置 第二十八节课
centos tomcat/resin安装配置 卸载系统自带的java tomcat安装配置 安装JDK resin安装配置 第二十八节课 tomcat和java都不需要编译 tom ...
- 【转】服务器证书安装配置指南(Weblogic)
服务器证书安装配置指南(Weblogic) 详情请点击: http://verisign.itrus.com.cn/html/fuwuyuzhichi/fuwuqizhengshuanzhuangpe ...
- 1.App爬取相关库的安装(安装Charles及手机端证书安装配置)
一.官网下载Charles安装包: https://www.charlesproxy.com/download1.下载对应版本 我这里下载的是 win 64 bit (下载完解压,双击打开charle ...
- nginx二级域名指向不同文件项目配置
需要使用泛域名解析, 并且加上空的判断,以保证没有二级域名的也可以访问 核心配置 server_name ~^(?<subdomain>.+)\.caipudq\.cn$;if ( $su ...
随机推荐
- Dva三种方式实现dispatch的Promise回调
Dva2.0及以上版本 使用官方自带的Promise // 业务组件 e.g: Tags.js dispatch({ type: 'user/add', payload: {}, // 需要传递的信息 ...
- Win10升级惹的祸,Oracle服务全没有了,怎么解决?
最近Win10自动升级,升级后各种服务全部没了,心已经凉了一半... 百度\Google了一大堆,无非就几种:卸载重装,还原到上一版Win10,甚至重装系统,对于正式使用的库来说,够崩溃的了.. 搜寻 ...
- 在webstorm中配置sass的自动编译,并且可以指定编译后的css的目录.
参考: WebStorm-2018.2-Help-Sass, Less, and SCSS 作者:tobyDing链接:https://www.jianshu.com/p/0fe52f149cab來源 ...
- npm配置国内镜像资源+淘宝镜像
将npm的注册表源设置为国内的镜像 1.国内用户,建议将npm的注册表源设置为国内的镜像,可以大幅提升安装速度 2.国内优秀npm镜像推荐及使用:http://riny.net/2014/cnpm/ ...
- java中循环遍历实体类的属性和数据类型以及属性值
package com.walkerjava.test; import java.lang.reflect.Field; import java.lang.reflect.InvocationTarg ...
- @RequestMapping的Ant风格URL
Ant风格资源地址支持3中匹配符 ? 匹配文件名中一个字符. * 匹配 文件名中任意字符 ** 匹配多层路径 例如 /hello/*/myspring 匹配 /hello/abc/mysprin ...
- 【堆】【洛谷例题】p1090 p1334 p1177
(都是比较简单的典型的而且都是小根堆的例题) p1090 合并果子[传送门] 算法分析:要尽量使用最小的体力合并完所有果子,那么每次合并的两堆果子应该是这所有堆中最小的一个(因为越先合并的堆要被算的次 ...
- cmd非运行完再保存,结果显示&保存同时进行
#coding:utf-8 """ fps信息获取到文件 """ import sys import subprocess class Lo ...
- Mock.js常用占位符——Basic、Date、Color
1. Basic 在通过占位符引用方法时, Mock.mock('@boolean') : Mock.mock('@boolean()') 都可以调用方法 方法 含义 使用举例 Random.bo ...
- nginx插入lua脚本访问redis
目标:收集用户日志 流程: 浏览器端get方法将数据传到nginx服务 nginx收集到数据,执行内嵌lua脚本,访问redis,根据token获得用户id 将日志信息存入文件 1.nginx安装,参 ...