nginx配置https 文件引入

以下文件均在nginx的conf目录下面

坐标:nginx.conf
#user  nobody;
worker_processes  8;

 

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;

events {
    worker_connections  65535;
}

http {
    include       mime.types;
    server_names_hash_bucket_size 128;
    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;
    include onlyoffice-*.conf;
}
 
坐标:onlyoffice-documentserver-ssl.conf 与 nginx.conf 同级目录
include includes/onlyoffice-http.conf;
## Normal HTTP host
server {
    listen 0.0.0.0:8083;
    listen [::]:8083 default_server;
    server_name _;
    server_tokens off;
    ## Redirects all traffic to the HTTPS host
    root /nowhere; ## root doesn't have to be a valid path since we are redirecting
    rewrite ^ https://$host$request_uri? permanent;
}
#HTTP host for internal services
server {
    listen 127.0.0.1:8083;
    listen [::1]:8083;
    server_name localhost;
    server_tokens off;
     include includes/onlyoffice-documentserver-common.conf;
    include includes/onlyoffice-documentserver-docservice.conf;

}
server {
    listen 80;
    server_tokens off;
    ## Redirects all traffic to the HTTPS host
    root /nowhere; ## root doesn't have to be a valid path since we are redirecting
    rewrite ^ https://$host$request_uri? permanent;
}
## HTTPS host
server {
    listen       443 ssl;
    server_name www.baidu.com;
    server_tokens off;
    root /usr/share/nginx/html;
    ssl on;
    ssl_certificate      doc.pem;
    ssl_certificate_key  doc.key;
   ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_prefer_server_ciphers   on;
    add_header Strict-Transport-Security max-age=31536000;
    add_header X-Content-Type-Options nosniff;

    include includes/onlyoffice-documentserver-*.conf;
}
server {
    listen       443 ssl;
    server_name  localhost(可替换自己的域名);
    ssl_certificate      2017.pem;
    ssl_certificate_key  2017.key;

 
    client_body_timeout 10s;
    client_header_timeout 10s;
    large_client_header_buffers 4 8k;
 client_header_buffer_size 1k;
 
 #ssl_session_cache    shared:SSL:1m;
    #ssl_session_timeout  5m;
    #ssl_ciphers  HIGH:!aNULL:!MD5;
    #ssl_prefer_server_ciphers  on;
    charset utf-8;
    location /tr_north{
         proxy_pass  http://tr_north;
        proxy_http_version 1.1;
        proxy_set_header   Connection       "";
        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_connect_timeout 6s;
        proxy_send_timeout 6s;
        proxy_read_timeout 6s;
        proxy_buffer_size 4k;
        proxy_buffers 32 4k;
        proxy_busy_buffers_size 64k;
        client_max_body_size 10m;
        client_body_buffer_size 128k;
    }
 location /tr_north_test{
         proxy_pass  http://tr_north_test;
        proxy_http_version 1.1;
        proxy_set_header   Connection       "";
        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_connect_timeout 6s;
        proxy_send_timeout 6s;
        proxy_read_timeout 6s;
        proxy_buffer_size 4k;
        proxy_buffers 32 4k;
        proxy_busy_buffers_size 64k;
        client_max_body_size 10m;
        client_body_buffer_size 128k;
    }
    location /{
         proxy_pass  http://docservice;
        proxy_http_version 1.1;
        proxy_set_header   Connection       "";
        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_connect_timeout 2;
        client_max_body_size    1000m;
    }

}
坐标:includes/onlyoffice-http.conf
upstream  tr_north{
    ip_hash;
    server 127.0.0.1:8089 weight=3 max_fails=1 fail_timeout=90s;   
    #keepalive 20;
}
upstream  tr_north_test{
    ip_hash;
    server 127.0.0.1:9080 weight=3 max_fails=1 fail_timeout=90s;     
    #keepalive 20;
}
proxy_cache_path temp/
  levels=1:2
  keys_zone=fonts_cache:1m
  inactive=1d
  max_size=256m;
map $http_host $this_host {
    "" $host;
    default $http_host;
}
map $http_x_forwarded_proto $the_scheme {
     default $http_x_forwarded_proto;
     "" $scheme;
}
map $http_x_forwarded_host $the_host {
    default $http_x_forwarded_host;
    "" $this_host;
}
map $http_upgrade $proxy_connection {
  default upgrade;
  "" close;
}
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Proto $the_scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

erizhu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值