惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
IT之家
IT之家
B
Blog
博客园_首页
量子位
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
J
Java Code Geeks
H
Help Net Security
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News

俗子

awk常用命令及功能 istio 配置 k8s 节点控制 dns 私有服务器 SeaFile 网盘 golang 私有包 verdaccio 前端私有源 chrony 时间同步 k8s 问题集锦 gitlab jenkins k8s 部署 linux 多显示器管理 mysql记录 服务器ssh登录配置 域名信息收集工具 ssh port forward redis拾遗-性能指标 逆向工具
nginx 日常
俗子 · 2019-03-13 · via 俗子

遇到的一些问题

  • 大文件无法上传
  • 1
    2
    3
    4
    server{
    client_max_body_size 30m; # 默认是1m
    ...
    }

    常用配置

    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
    server {
    listen 80;
    server_name hostname.com;
    location / {
    if ($request_method = GET) {
    rewrite ^ https://$host$request_uri? permanent; # http强制跳转
    }
    return 405;
    }
    access_log /var/log/nginx/hostname/hostname.log main;
    }
    server {
    listen 443;
    server_name hostname.com;
    client_max_body_size 10m;
    ssl on;
    ssl_certificate /etc/nginx/ssl/hostname.com.crt; # ssl证书
    ssl_certificate_key /etc/nginx/ssl/hostname.com.key;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_redirect off;
    # keepalive + raven.js is a disaster
    keepalive_timeout 0;
    location / {
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_pass http://localhost:8000;
    add_header Strict-Transport-Security "max-age=31536000";
    }
    access_log /var/log/nginx/hostname/hostname_ssl.log main;
    error_log /var/log/nginx/hostname/hostname_ssl_error.log;
    }

    正则配置

    • 等号(=):表示完全匹配规则才执行操作
    • 1
      location = / {}
      • 波浪号(~):表示执行正则匹配,但区分大小写
      • 1
        location ~ /page/\d{1,3} {}
        • 波浪号与星号(~*):表示执行正则匹配,但不 区分大小写
        • 1
          location ~* /\.(jpg|jpeg|gif) {}
          • 脱字符与波浪号(^~):表示普通字符匹配,前缀匹配有效,配置生效
          • 1
            location ^~ /images/ {}  # http://{hostname}/images/test
            • @ :定义一个location,用于处理内部重定向
            • 1
              2
              3
              4
              location @error {
              proxy_pass http://error;
              }
              error_page 404 @error;