文章

Leanotes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
log_format  reports  '$remote_addr|$time_iso8601|$http_x_forwarded_for|$remote_user|$scheme|$uri|$is_args|'
                     '$args|$status|$request_method|$request_body|$request_time|$request_length|$request_completion|$request_filename|'
                     '$http_referer|$body_bytes_sent|$host|$http_host|$proxy_host|$upstream_addr|$upstream_cache_status|'
                     '$upstream_response_length|$upstream_status|$upstream_response_time|$http_user_agent';


upstream leanotes {
    server localhost:8081;
}

server {
    listen 80;
    server_name note.fscloude.cn;
    rewrite ^(.*)$ https://note.fscloude.cn:443$request_uri;
}

server {
    listen 443 ssl http2;
    server_name note.fscloude.cn;
    #valid_referers www.fscloude.cn fscloude.cn ;
    #if ($invalid_referer) {
    #    #rewrite ^(.*)$ https://www.fscloude.cn:443$request_uri;
    #    return 404;
    #}
  
    access_log  /opt/leanotes/leanote/logs/nginx/leanotes_access.log  reports;
    error_log   /opt/leanotes/leanote/logs/nginx//leanotes_error.log;

    ssl_certificate /opt/leanotes/leanote/nginx_cerl/note.fscloude.cn.crt;
    ssl_certificate_key /opt/leanotes/leanote/nginx_cerl/note.fscloude.cn.key;

    #腾讯文档配置方式
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;


    # 只允许https访问
    add_header Strict-Transport-Security "max-age=63072000";
  
    client_max_body_size 0;

    # 反向代理时,隐藏上游服务器信息
    proxy_hide_header Referrer-Policy;
    add_header Referrer-Policy strict-origin-when-cross-origin;

    if ($http_host = "") {
        set $http_host_with_default "note.fscloude.cn";
    }
  
    if ($http_host != "") {
        set $http_host_with_default $http_host;
    }

    proxy_set_header Host $http_host_with_default;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-Ssl on;

    

#    location ~ .*\.(gif|jpg|png|jpeg|css|js|ico|css|js)(.*) {
#        proxy_redirect off;
#        proxy_set_header Host $host;
#        proxy_pass http://leanotes;
#        proxy_cache leanote_cache;
#        proxy_cache_valid 200 302 301 1m;
#        proxy_cache_valid 404 1m;
#        proxy_cache_valid any 1m;
#        expires 2m;
#        index  index.html index.htm;
#        error_page  404 /404.html;
#    }

    location /  {
#        limit_req zone=leaNote_req burst=50;
        proxy_pass http://leanotes;
        index  index.html index.htm;
        error_page  404 /404.html;
    }
}
本文由作者按照 CC BY 4.0 进行授权