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施加的安全限制(指一个域下的文档或脚本试图去请求另一个域下的资源,这 ...
随机推荐
- ubuntu linux断点续传下载工具 uGet 的安装
网址 http://ugetdm.com/downloads-ubuntu 使用命令行安装 sudo add-apt-repository ppa:plushuang-tw/uget-stable s ...
- May 03rd 2017 Week 18th Wednesday
Truth needs no colour; beauty, no pencil. 真理不需要色彩,美丽不需要涂饰. There is no absoulte truth and everlastin ...
- C++ new new[]详解
精髓: operator new()完成的操作一般只是分配内存:而构造函数的调用(如果需要)是在new运算符中完成的. operator new和new 运算符是不同的,operator new只分配 ...
- C++学习之虚析构函数
什么样的情况下才需要虚析构函数? 类需要控制自己的对象执行一系列操作时发生什么样的行为,这些操作包括:创建(对象).拷贝.移动.赋值和销毁.在继承体系中,如果一个类(基类或其派生的类)没有定义拷贝控制 ...
- 二进制安装mysql5.6
安装依赖包 yum install -y libaio yum install -y perl perl-devel 解压 mkdir /opt/mysql mv mysql-5.6 ...
- python3中使用HTMLTestRunner.py报ImportError: No module named 'StringIO'的解决办法
.原因是官网的是python2语法写的,看官手动把官网的HTMLTestRunner.py改成python3的语法: 参考:http://bbs.chinaunix.net/thread-415474 ...
- 2018.7.30 Oracle的Blog数据库类型读取和存
package com.lanqiao.shopping.test; import java.io.BufferedInputStream; import java.io.BufferedOutput ...
- MySQL 存储过程参数IN OUT INOUT区别
MySQL 存储过程参数IN OUT INOUT对比 一.IN -- 创建测试存储过程 delimiter // create procedure p_in ( IN num int ) begin ...
- C#语言概述
C#语言概述 一..NET Framework .NET Framework是Windows的一个不可或缺的组件,它包括公共语言运行库(CLR)和类库两部分. CLR是Microsoft的公共语言基础 ...
- java基础 静态 static 问在多态中,子类静态方法覆盖父类静态方法时,父类引用调用的是哪个方法?
多态 package com.swift.jiekou; public class Jicheng_Tuotai_jingtai_diaoyong { public static void main( ...