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施加的安全限制(指一个域下的文档或脚本试图去请求另一个域下的资源,这 ...
随机推荐
- ODBC驱动程序丢失解决方法
今天运行SqlDbx连接数据库的时候报错,提示没有找到相应的ODBC driver,打开ODBC管理面板一看,发现里面的驱动程序都不见了.这时想起今天卸载了一个成本核算软件后成这样的,网上搜索一下只需 ...
- 卷积神经网络CNN在自然语言处理的应用
摘要:CNN作为当今绝大多数计算机视觉系统的核心技术,在图像分类领域做出了巨大贡献.本文从计算机视觉的用例开始,介绍CNN及其在自然语言处理中的优势和发挥的作用. 当我们听到卷积神经网络(Convol ...
- centos7安装python3和ipython
CentOS7下默认系统自带python2.X的版本,这个版本被系统很多程序所依赖,所以不建议删除,如果使用最新的Python3那么我们知道编译安装源码包和系统默认包之间是没有任何影响的,所以可以安装 ...
- CUDA线性内存分配
原文链接 概述:线性存储器可以通过cudaMalloc().cudaMallocPitch()和cudaMalloc3D()分配 1.1D线性内存分配 1 cudaMalloc(void**,int) ...
- poj_3641_Pseudoprime numbers
Fermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). Th ...
- maven入门2
1.修改maven本地仓库位置 没有效果,在新建项目时还是转跳到默认配置 在默认仓库位置添加修改后的setting文件,失败 修改成功,原因是前面修改的是setting而我们需要修改的是default ...
- C#基础-面向对象-多态
多态,不同对象对同一方法的不同实现 使用abstract关键字表示抽象类 // 表示是一个抽象类 public abstract class Animal { private string name; ...
- java.lang.UnsupportedOperationException 原因以及解决方案
如下代码: Map[] cardProds = JsonUtils.getObject(oldCartValue, new TypeReference<Map[]>(){}); List& ...
- python中enumerate函数使用
enumerate()说明 enumerate()是python的内置函数 enumerate在字典上是枚举.列举的意思 对于一个可迭代的(iterable)/可遍历的对象(如列表.字符串),enum ...
- JQuery制作网页—— 第一章 JavaScript基础
1. JavaScript(弱类型语言):是一种描述性语言,也是一种基于对象(Object)和事件驱动(Event Driven)的,并具有安全性能的脚本语言. 特点:1.主要用来在HTML页面中添加 ...