关于https工程的简单nginx的简单配置

1.下载域名的ssl证书,由于项目部署在阿里云上,就用了阿里推荐的赛门铁克,用Let‘s Encrypt的也不错。

2.nginx的配置如下:

worker_processes  8;

error_log  error.log;

events {
    worker_connections  1024;
}

http{
    server_tokens off;
    include       mime.types;
    default_type  application/octet-stream;

    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/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
      #工程1
    upstream project1_http{
        #工程1端口
        server ip地址:8190;
    }
    upstream project2_http{
        #工程2端口
        server ip地址:8089;
    }
    server {
        listen       80;
        server_name  website_http;
        charset utf-8;
        access_log  logs/web.log;     //域名后子访问名
        location /project1/ {
            proxy_pass  http://project1_http/;
            proxy_redirect off;
            proxy_intercept_errors on;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size 100M;
            proxy_connect_timeout 300s;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_buffer_size 64k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_ignore_client_abort on;
            #proxy_redirect default;
        }
        location /project2/ {
            proxy_pass  http://project2_http/;
            proxy_redirect off;
            proxy_intercept_errors on;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size 100M;
            proxy_connect_timeout 300s;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_buffer_size 64k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_ignore_client_abort on;
            #proxy_redirect default;
        }
    }
  #项目使用到了腾讯云的对象存储功能,用于存储图片、视频
    upstream cos-auth-server{
        #鉴权443口
        server ip地址:33575;
    }
    upstream project2_https{
        #项目443口
        server ip地址:8089;
    }
    server {
          listen 443;
          server_name website_https;
          ssl on;
          ssl_certificate cert/证书.pem;
          ssl_certificate_key cert/证书.key;
          ssl_session_timeout 5m;
          ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
          ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
          ssl_prefer_server_ciphers on;
          location /cosauth/ {
            proxy_pass  http://cos-auth-server/;
            proxy_redirect off;
            proxy_intercept_errors on;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size 100M;
            proxy_connect_timeout 300s;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_buffer_size 64k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_ignore_client_abort on;
            #proxy_redirect default;
        }
        location /project2/ {
            proxy_pass  http://project2_https/;
            proxy_redirect off;
            proxy_intercept_errors on;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size 100M;
            proxy_connect_timeout 300s;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
            proxy_buffer_size 64k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_ignore_client_abort on;
            #proxy_redirect default;
        }
    }
}

原文地址:https://www.cnblogs.com/daidao/p/8325352.html

时间: 2024-07-29 18:22:54

关于https工程的简单nginx的简单配置的相关文章

两种web最简单的负载均衡配置(nginx haproxy)

-------------------------------------------------------------- Centos 6.6 环境  php  http://lampol.blog.51cto.com/11662628/1851016 -------------------------------------------------------------- 负载均衡,英文名称为Load Balance,其意思就是分摊到多个操作单元上进行执行,例如Web服务器.FTP服务器

编译安装nginx及简单优化配置

一.背景 使用源码包安装lnmp架构及简单的优化配置 二.实验环境 rhel6.5 三.安装过程 1.nginx(提前装好gcc等编译器) (1) 下载源码包  http://nginx.org/ (2) tar -zxf nginx-1.8.1.tar.gz (3) cd nginx-1.8.1 vim auto/cc/gcc 修改第179行 (将本行注释,意为取消debug模式,) (4) ./configure --prefix=/usr/local/lnmp/nginx \ --with

nginx 配置管理 - 简单也复杂

由于涉及到h5与后端交互,跨域问题,所以公司的开放测试服务器让我们自己搞nginx.顺便提升一下nginx的实践. nginx的安装,没什么难度了,百度一堆,如果源码安装就一步步来吧.(最简单的方式:yum install nginx (centos), apt-get install nginx(ubuntu)) nginx.conf,作为最外层的配置文件,主要设置一些基础的配置就好了,如内存配置,日志格式配置,线程配置等,最后使用一个include conf.d/* 将其他配置文件包含进来即

Nginx+IIS简单的部署

随着互联网项目用户访问量不断上升,单点web服务器是无法满足大型高并发高负载的业务处理的,为了给web服务器做负载均衡方案,打算采用Nginx搭建负载均衡服务器,把用户请求分配到N个服务器来缓解服务器压力. Nginx简介:    Nginx (“engine x”) 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器 . Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的Rambler.ru 站点开发的,它已经在该站点运行超过四年多了

Nginx实现简单动静分离

笔者最近在开始学提高web性能方面的知识.本文将介绍使用Nginx做分布式部署,实现静动分离,并且分析性能. 静动分离,就是将css.js.jpg等静态资源和jsp等动态资源分开处理,以此提高服务器响应速度,提高性能. 下面给出的例子实现了静动分离,其中静态资源,如css.js.jpg等由Nginx服务器处理,直接获取磁盘资源,动态资源,如jsp等由tomcat服务器处理. 首先配置Nginx. nginx.conf的具体配置如下: Nginx服务器作为代理服务器,监听80端口,判断如果的访问动

初识Nginx,简单配置实现负载均衡(ubuntu + Nginx + tomcat)

工作需要,研究了一下Nginx的反向代理实现负载均衡,网上搜了一下教程,大多含糊不清,所以写下这个,权当总结,方便日后查看,如果能恰好帮到一些需要的人,那就更好了 先说需求,域名指向搭建了Nginx的服务器A,然后由A负载均衡到装有tomcat的服务器B和服务器C(不知道“由A负载均衡到B.C”这种说法对不对) 先说环境: 服务器ABC均为优麒麟(ubuntukylin)14.04 服务器A装有Nginx1.6.3 服务器B.C使用tomcat6 准备工作: 1.设置服务器A的IP为192.16

图文解说,初识Nginx,简单配置实现负载均衡(ubuntu + Nginx + tomcat)

工作需要,研究了一下Nginx的反向代理实现负载均衡,网上搜了一下教程,大多含糊不清,所以写下这个,权当总结,方便日后查看,如果能恰好帮到一些需要的人,那就更好了 先说需求,域名指向搭建了Nginx的服务器A,然后由A负载均衡到装有tomcat的服务器B和服务器C(不知道“由A负载均衡到B.C”这种说法对不对) 先说环境: 服务器ABC均为优麒麟(ubuntukylin)14.04 服务器A装有Nginx1.6.3 服务器B.C使用tomcat6 准备工作: 1.设置服务器A的IP为192.16

nginx搭建简单文件服务器

安装 sudo yum install -y nginx 配置 修改配置 sudo vi /etc/nginx/nginx.conf sudo vi /etc/nginx/default.d/default.conf 检查配置 sudo nginx -t sudo vi /var/log/nginx/error.log 启动服务 sudo service nginx start 访问服务 ip/my_dir 配置文件记录 $ cat /etc/nginx/nginx.conf # For mor

Nginx之二:nginx.conf简单配置(参数详解)

vim /usr/local/nginx/conf/nginx.conf #user  nobody; #程序运行使用账户 worker_processes  1; #启动的进程,通常设置成和cpu的数量相等 #全局错误日志级PID文件 #error_log  logs/error.log; #error_log  logs/error.log  notice; #error_log  logs/error.log  info; #pid        logs/nginx.pid; event