AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 784371
Accepted
Sebastian Schrader
Sebastian Schrader
Asked: 2016-06-17 04:55:50 +0800 CST2016-06-17 04:55:50 +0800 CST 2016-06-17 04:55:50 +0800 CST

如何在 nginx 中设置 HTTP 状态码原因短语

  • 772

伴随状态码的 HTTP 响应的原因短语不固定。与其退货,不如200 OK退货是合法的200 Everything fine。

nginx 为一些众所周知的状态码预定义了原因短语,但不是全部。例如,到目前为止,nginx 还不知道 RFC 6585 状态代码的原因短语511 Network Authentication Required。

如何在 nginx 中设置/更改状态码的原因短语?

http nginx http-status-code
  • 1 1 个回答
  • 1803 Views

1 个回答

  • Voted
  1. Best Answer
    Tim
    2016-06-17T11:38:20+08:002016-06-17T11:38:20+08:00

    您可以随时更改它并构建 Nginx,这非常容易。

    在

    src\https\ngx_http_header_filter_module.c
    

    改变

    ngx_string("200 OK"),
    

    随心所欲。

    要构建 Nginx,请遵循我编写的本指南,或任何其他“如何构建 Nginx”指南。这是它的核心,供参考

    cd /home/ec2-user
    mkdir nginx-build
    cd nginx-build
    service nginx stop
    yum groupinstall "Development Tools"
    yum install pcre-devel zlib-devel openssl-devel
    wget http://nginx.org/download/nginx-1.9.11.tar.gz
    wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
    wget https://github.com/openresty/headers-more-nginx-module/archive/v0.29.tar.gz
    tar -xzf nginx-1.9.11.tar.gz
    tar -xzf ngx_cache_purge-2.3.tar.gz
    tar -xzf v0.29.tar.gz
    tar -xzf 1.9.32.10.tar.gz    # Google Pagespeed, optional
    ngx_version=1.9.32.10
    wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${ngx_version}-beta.zip   # Google Pagespeed, optional
    cd ngx_pagespeed-release-1.9.32.10-beta   # Google Pagespeed, optional
    wget https://dl.google.com/dl/page-speed/psol/${ngx_version}.tar.gz   # Google Pagespeed, optional
    cd ../nginx-1.9.9
    # Note that I have no idea what the next line does but it was in the official guide
    PS_NGX_EXTRA_FLAGS="--with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc"
    # Safe option, slower, lots of modules included
    #./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --add-module=/tmp/ngx_cache_purge-2.3 --add-module=/tmp/headers-more-nginx-module-0.29 --with-http_realip_module --add-modeule=../ngx_pagespeed-release-1.9.32.10-beta
    # Many plugins removed, extra optimisations including some JUST for the machine it's compiled on
    ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-threads --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=native' --add-module=../ngx_cache_purge-2.3 --add-module=../headers-more-nginx-module-0.29 --with-http_realip_module --add-module=../ngx_pagespeed-release-1.9.32.10-beta
    make && make install
    make clean  (NB: optional)
    service nginx start
    
    • 2

相关问题

  • 设置 http 代理以使用 Web 界面?

  • 无法连接到 Ubuntu Desktop 中的端口 80 或 VMWare Workstation 6.52 中的 Server 9.04

  • IIS 7.5 (Windows 7) - HTTP 错误 401.3 - 未经授权

  • 为什么有些网站的网址中没有“www”就无法显示?[关闭]

  • Tomcat 6 HTTP 日志滚动和清除

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve