nginx配置及HTTPS配置示例
一、nginx简单配置示例
user www www; worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; #最大文件描述符
worker_rlimit_nofile ; events
{
use epoll;
worker_connections ;
} http
{
include conf/mime.types;
default_type application/octet-stream; keepalive_timeout ; tcp_nodelay on; upstream www.xxx.com {
server 192.168.1.2:;
server 192.168.1.3:;
server 192.168.1.4:;
server 192.168.1.5:;
} upstream blog.xxx.com {
server 192.168.1.7:;
server 192.168.1.7:;
server 192.168.1.7:;
} server
{
listen ;
server_name www.xxx.com; location / {
proxy_pass http://www.zyan.cc;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
} log_format www_xxx_com '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /data1/logs/www.log www_xxx_com;
} server
{
listen ;
server_name blog.xxx.com; location / {
proxy_pass http://blog.zyan.cc;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
} log_format blog_xxx_com '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /data1/logs/blog.log blog_xxx_com;
}
}
二、HTTPS配置示例
upstream xxx_xxx_xxx {
server 192.168.1.7:;
server 192.168.1.7:;
server 192.168.1.7:;
}
server {
listen ;
server_name xxx.xxx.xxx;
access_log /home/chenwebstore1/logs/xxx.xxx.xxx/https./access.log combined;
error_log /home/chenwebstore1/logs/xxx.xxx.xxx/https./error.log error;
ssl on;
ssl_certificate keys/xxx.xxx.xxx.pem;
ssl_certificate_key keys/xxx.xxx.xxx.key;
ssl_session_cache shared:ssl.xxx.xxx.xxx:128k;
ssl_protocols TLSv1 TLSv1. TLSv1.;
location / {
proxy_pass http://xxx_xxx_xxx;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
}
}
其中ssl_certificate_key文件格式为:
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
其中ssl_certificate文件格式(后缀可以为cer)为:
(Certificate:)
----BEGIN CERTIFICATE-----
----END CERTIFICATE-----
(Intermediate Certificate:)
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
上面这三段字符串值可以在HTTPS证书申请时获取到。
nginx配置及HTTPS配置示例的更多相关文章
- Nginx下的https配置
https: https(Secure Hypertext Transfer Protocol) 安全超文本传输协议 它是以安全为目标的http通道,即它是http的安全版.它使用安全套接字层(SSL ...
- Nginx HA 及https配置部署
Nginx HA 整体方案架构为: (内网192.168.199.5) +-----------VIP----------+ | | | | Master Backup 192.168.199.90 ...
- nginx常用配置系列-HTTPS配置
接上篇,nginx配置系列 HTTPS现在已经很流行,特别是AppStore上线的应用要求使用HTTPS进行通信,出于安全考虑也应该使用HTTPS,HTTPS配置需要准备证书文件,现在也有很多免费证书 ...
- nginx普通配置/负载均衡配置/ssl/https配置
1.nginx普通配置 server { listen ; server_name jqlin.lynch.com; access_log /var/log/nginx/main.log main; ...
- nginx http跳https配置
为了数据传输的安全性以及防止网页被恶意篡改,现在大多数网站都配置了https. 如何保证用户都是通过https进行访问呢? 如果有用到nginx,我们可以配置强制跳转. 在nginx配置中添加: se ...
- 微服务探索之路04篇k8s增加子节点,metrics资源监控,ingress-nginx域名配置及https配置
1 k8s增加子节点 1.1 子节点服务器安装docker,使用脚本自动安装 curl -fsSL https://get.docker.com | bash -s docker --mirror A ...
- nginx基本用法和HTTPS配置
nginx作用讲解:1.反向代理:需要多个程序共享80端口的时候就需要用到反向代理,nginx是反向代理的一种实现方式.2.静态资源管理:一般使用nginx做反向代理的同时,应该把静态资源交由ngin ...
- Nginx之https配置 - 运维笔记 (http->https强转)
一.Nginx安装(略)安装的时候需要注意加上 --with-http_ssl_module,因为http_ssl_module不属于Nginx的基本模块.Nginx安装方法: # ./configu ...
- Nginx跨域及Https配置
一.跨域 1. 什么是跨域? 跨域:指的是浏览器不能执行其他网站的脚本.它是由浏览器的同源策略造成的,是浏览器对javascript施加的安全限制(指一个域下的文档或脚本试图去请求另一个域下的资源,这 ...
随机推荐
- 如何在windows下运行Linux命令?(转载)
在windows上可以运行或使用linux下面的命令吗?可以,小编今天就来分享怎么样让Windows支持Linux命令,做这些安装和设置后,就可以非常方便的在windows系统中使用linux下面的命 ...
- LA 3938 动态最大连续和
题目链接:https://vjudge.net/contest/146667#problem/C 题意:动态的求一个区间的最大连续和. 分析: 看上去可以RMQ去做,但是,当分成两个部分,原来的部分的 ...
- 画X,模拟水题
题目链接:http://codeforces.com/contest/404/problem/A #include <stdio.h> #include <string.h> ...
- 2018.7.6 js实现点击事件---点击小图出现大图---时间定时器----注册表单验证
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- ROS机器人程序设计
在<ROS机器人程序设计>中,在第二章创建节点时给出一个接收和发送的例子,但是按照书中步骤编译时,遇到按个三个问题,现在罗列出来解决方案供参考. 建议在工作空间直接输入 catkin_ ...
- Laplace算子和Laplacian矩阵
1 Laplace算子的物理意义 Laplace算子的定义为梯度的散度. 在Cartesian坐标系下也可表示为: 或者,它是Hessian矩阵的迹: 以热传导方程为例,因为热流与温度的梯度成正比,那 ...
- Erwin 简单使用
1. 物理设计:汉译英过程 ① Logical 中操作:Tools-Names-Edit Naming Standards…-Glossary选项import,导入内容为编辑好的CSV文件(只包含中文 ...
- vue项目中的函数封装
项目中一般都会有fun.js这类的文件,里面有各种的如转换时间格式的,处理转换的等等函数方法. 其实经常用到的去获取基本数据的接口也可以封装成一个方法,方便复用. 如上面所标,获取列表数据之前需要先获 ...
- BZOJ1854: [Scoi2010]游戏(二分图匹配)
题目描述 lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1,10000]之间的数表示.当他使用某种装备时,他只能使用该装备的某一个属性.并且每种装备 ...
- linux定时任务及练习
第1章 定时任务 1.1 什么是定时任务 相当于闹钟每天叫你起床 设定一个时间去做某件事 1.2 系统定时任务 [root@zeq ~]# ll -d /etc/cron* drwxr-xr-x. 2 ...