一、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配置示例的更多相关文章

  1. Nginx下的https配置

    https: https(Secure Hypertext Transfer Protocol) 安全超文本传输协议 它是以安全为目标的http通道,即它是http的安全版.它使用安全套接字层(SSL ...

  2. Nginx HA 及https配置部署

    Nginx HA 整体方案架构为: (内网192.168.199.5) +-----------VIP----------+ | | | | Master Backup 192.168.199.90 ...

  3. nginx常用配置系列-HTTPS配置

    接上篇,nginx配置系列 HTTPS现在已经很流行,特别是AppStore上线的应用要求使用HTTPS进行通信,出于安全考虑也应该使用HTTPS,HTTPS配置需要准备证书文件,现在也有很多免费证书 ...

  4. nginx普通配置/负载均衡配置/ssl/https配置

    1.nginx普通配置 server { listen ; server_name jqlin.lynch.com; access_log /var/log/nginx/main.log main; ...

  5. nginx http跳https配置

    为了数据传输的安全性以及防止网页被恶意篡改,现在大多数网站都配置了https. 如何保证用户都是通过https进行访问呢? 如果有用到nginx,我们可以配置强制跳转. 在nginx配置中添加: se ...

  6. 微服务探索之路04篇k8s增加子节点,metrics资源监控,ingress-nginx域名配置及https配置

    1 k8s增加子节点 1.1 子节点服务器安装docker,使用脚本自动安装 curl -fsSL https://get.docker.com | bash -s docker --mirror A ...

  7. nginx基本用法和HTTPS配置

    nginx作用讲解:1.反向代理:需要多个程序共享80端口的时候就需要用到反向代理,nginx是反向代理的一种实现方式.2.静态资源管理:一般使用nginx做反向代理的同时,应该把静态资源交由ngin ...

  8. Nginx之https配置 - 运维笔记 (http->https强转)

    一.Nginx安装(略)安装的时候需要注意加上 --with-http_ssl_module,因为http_ssl_module不属于Nginx的基本模块.Nginx安装方法: # ./configu ...

  9. Nginx跨域及Https配置

    一.跨域 1. 什么是跨域? 跨域:指的是浏览器不能执行其他网站的脚本.它是由浏览器的同源策略造成的,是浏览器对javascript施加的安全限制(指一个域下的文档或脚本试图去请求另一个域下的资源,这 ...

随机推荐

  1. Firefox浏览器 页面滑动卡帧问题

    在设置里关闭"平滑滚动"选项即可,猎豹似乎没有,遭黑

  2. IOS照相机的启动,图片的读取,存储demo

    #import @interface ViewController : UIViewController@property (retain, nonatomic) IBOutlet UIImageVi ...

  3. Robin-Karp algorithm 字符串的匹配

    有关字符串的匹配问题,有很好的算法,即KMP算法,但是还有一种其实经常使用到的算法是Rabin-Karp算法,它是使用hash的原理来进行字符串匹配的.具体的做法如下. Rabin-Karp算法是由R ...

  4. 转:SSM框架——使用MyBatis Generator自动创建代码

    转:https://blog.csdn.net/zhshulin/article/details/23912615 这两天需要用到MyBatis的代码自动生成的功能,由于MyBatis属于一种半自动的 ...

  5. 7 MSSQL数据库备份与恢复

    0 MSSQL数据库备份 1 SQLAgent配置 2 设置连接属性 3 输入SA账号密码 4 SQL备份脚本配置 5 生成SQL全量备份脚本 6 生成SQL差异备份脚本 7 修改SQL差异备份脚本 ...

  6. 问题 C: B C++时间类的运算符重载

    题目描述 C++时间类的运算符重载 定义一个时间类Time,其数据成员为表示时间的小时(hour).分(minute),秒(second). 重载运算符“+”,使之能用于时间对象的加法运算:重载运算符 ...

  7. EF问题集合

    1. 在使用数据迁移的过程中,如果手工删除了本地数据库之后,再次尝试连接被删除的数据库,会有以下提示: System.Data.SqlClient.SqlException (0x80131904): ...

  8. nginx架构分析之 模块化

    Nginx涉及到的模块分为核心模块.标准HTTP模块.可选HTTP模块.邮件服务模块以及第三方模块等五大类. 核心模块 核心模块是指Nginx服务器正常运行时必不可少的模块,它们提供了Nginx最基本 ...

  9. System.IO 二

    接着上篇的来  System.IO FileSystemWatcher    指向这个签名的方法   可以监听目录发生了什么事件 例如: static void Main(string[] args) ...

  10. 基于SOA架构和流媒体技术的在线教育平台的研究

    简介 现代远程教育是指通过音频.视频(直播或录像)以及包括实时和非实时在内的计算机技术把课程传送的教育.现代远程教育是随着现代信息技术的发展而产生的一种新型教育方式.计算机技术.多媒体技术.通信技术的 ...