html tool

显示标签为“nginx”的博文。显示所有博文
显示标签为“nginx”的博文。显示所有博文

2024年6月11日星期二

nginx编译知道openssl源码,make提示/bin/sh: line 0: cd: auto/lib/openssl/conf: Not a directory 的解决

 问题:

编译参数:

./configure --prefix=/usr/local/nginx --with-openssl=/tool/openssl1.1.0w --with-http_stub_status_module  --with-http_v2_module  --with-http_gzip_static_module  --with-http_sub_module --with-stream --with-stream_ssl_module  --with-http_realip_module  --with-http_gzip_static_module --with-http_ssl_module

结果make是提示问题如下:

# make

make -f objs/Makefile
make[1]: Entering directory `/tool/nginx-1.27.0'
cd auto/lib/openssl/conf \
&& if [ -f Makefile ]; then make clean; fi \
&& ./config --prefix=/tool/nginx-1.27.0/auto/lib/openssl/conf/.openssl no-shared no-threads  \
&& make \
&& make install_sw LIBDIR=lib
/bin/sh: line 0: cd: auto/lib/openssl/conf: Not a directory
make[1]: *** [auto/lib/openssl/conf/.openssl/include/openssl/ssl.h] Error 1
make[1]: Leaving directory `/root/tool/nginx-1.27.0'
make: *** [build] Error 2

解决方式:
将openssl1.1.0w的目录移动为openssl修改编译参数中的
--with-openssl=/tool/openssl1.1.0w
--with-openssl=/tool/openssl 
在编译和make就可以了
PS:我在nginx1.24.0/1.27.0上都遇到这个问题,go了一下大家都在改Makefile文件中的引用,反向改改也ok,想来是./configure脚本对path中的.处理有bug吧

2023年2月15日星期三

转:ningix *21 opendir() "/xxx" failed (13: Permission denied) 处理

 问题:nginx err log提示 “21 opendir() "/data/nginx_s" failed (13: Permission denied)”


参考:https://ramk.co.in/nginx-opendir-failed-13-permission-denied/

处理:

Also if you are using a centos 7 box, SELinux is enabled by default. We can set it to persmissive mode by using the following command.

sudo setenforce permissive

But SELinux will be enabled again on restart.

转:bind() to 0.0.0.0:xx failed (13: Permission denied)处理

 问题:nginx无其他程序的端口占用,但启动时提示:bind() to 0.0.0.0:18089 failed (13: Permission denied)

解决:

https://blog.csdn.net/nalw2012/article/details/101275003

系统启动Nginx后,报 [emerg] bind() to 0.0.0.0:XXXX failed (13: Permission denied)错误的处理方式,分为两种:


1、端口小于1024的情况

[emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

原因是1024以下端口启动时需要root权限,所以sudo nginx即可。


2、端口大于1024的情况:

[emerg] bind() to 0.0.0.0:8090 failed (13: Permission denied)

这种情况,需要如下操作:


首先,查看http允许访问的端口:

semanage port -l | grep http_port_t

提示结果如下:


http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000


其次,将要启动的端口加入到如上端口列表中

semanage port -a -t http_port_t -p tcp 8090

如此即可解决如上问题。


安装semanage

如semanage 未安装,使用命令

yum install -y semanage 安装时提示


No package semanage available.


改用下面的命令

yum provides semanage


出现提示


policycoreutils-python-2.5-33.el7.x86_64 : SELinux policy core python utilities

Repo : base

Matched from:

Filename : /usr/sbin/semanage


然后执行下面的命令即可安装。

yum install -y policycoreutils-python.x86_64


2021年5月10日星期一

转:nginx反向代理转发上传文件是否缓存

 参考:

https://blog.csdn.net/wuqing2012mxd/article/details/105768686

解决方案:根据官方文档说的把proxy_request_buffering设置成off,请求的正文就不会缓存,而是实时与代理服务器交互.


https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering

Syntax:proxy_request_buffering on | off;
Default:
proxy_request_buffering on;
Context:httpserverlocation

This directive appeared in version 1.7.11.

Enables or disables buffering of a client request body.

When buffering is enabled, the entire request body is read from the client before sending the request to a proxied server.

When buffering is disabled, the request body is sent to the proxied server immediately as it is received. In this case, the request cannot be passed to the next server if nginx already started sending the request body.

2021年3月1日星期一

windows 的nginx 路径配置写/方式的

 

        location / {

            root   html;

            index  index.html index.htm;

        }

        location /pixi/ {

            alias D:/home/nocbackup/tool/network/nginx-1.19.7/pixi/ ;

            autoindex on;

        }


2018年12月24日星期一

nginx ba 配置


vim /etc/nginx/conf.d/default.conf

  8     location / {
  9         root   /usr/share/nginx/html;
 10         index  index.html index.htm;
 11      
 12 #        #proxy_pass http://up_tip/;
 13 #        add_header Cache-Control 'no-store';
 14 #        # anti Clickjacking
 15 #        add_header X-Frame-Options "SAMEORIGIN";
 16 #    
 17 #        try_files $uri $uri/ /index.html;
 18 #        auth_basic "Restricted Area, Please authoricate yourself.";
 19 #        auth_basic_user_file /etc/nginx/conf.d/htppwasswd;
 20 #        autoindex off;
 21      
 22     }
 23      
vim /etc/nginx/conf.d/htppwasswd
${name}:${passwd}

nginx -s reload 就ok了

2018年5月15日星期二

nginx-ssl设置



http://blog.51cto.com/sohudrgon/1596946


.ssl_session_cache指令
语法:
Syntax:ssl_session_cache off | none | [builtin[:size]] [shared:name:size];
默认值:
Default:ssl_session_cache none;
配置段:
Context:http, server

设置用来存储SSL会话缓存类型和大小。
缓存类型分类:
off         #硬关闭:明确告诉客户端这个会话不可用;
none     #软关闭:告诉客户端会话能被重用,但Nginx实际上不会重用它们。
builtin     #OpenSSL内置缓存,仅可用于一个工作进程;缓存大小用户会话数来指定。注意:使用该指令会导致内存碎片,慎用。
shared      #位于所有工作进程的共享缓存。缓存大小用字节数指定,1MB缓存能容纳4000会话。每个共享缓存必须拥有字节的名称,同名的缓存可以用于多个虚拟主机。

你可以同时使用builtin和shared,实例如下
ssl_session_cache builtin:1000 shared:SSL:10m;

然而,只使用共享内存而不使用builtin缓存,将更有效。

13.ssl_session_timeout指令
语法:
Syntax:ssl_session_timeout time;
默认值:
Default:ssl_session_timeout 5m;
配置段:
Context:http, server
设置客户端能够重复使用存储在缓存中的会话参数时间。

2018年5月9日星期三

nginx - upstream_cache_status 和 upstream_status



https://www.cnblogs.com/kevingrace/p/8185218.html

$upstream_cache_status
显示缓存的状态
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
nginx在web应用上的占用率越来越高,其带的模块也越来越来。nginx_cache算是一个,虽和专业的cache工具相比略逊一筹,但毕竟部署简单,不用另装软件
和资源开销,所以在web cache中也占了比重不小的一席。不过像squid和varnish等cache软件都自带的有cache查看工具,而且还可以方便的在http header上
显示出是否命中。nginx主要还是做web使用。所以想要得出命中率的大小,还需要通过日志进行统计,不过想要增加header查看倒很简单
  
1)在http header上增加命中显示
nginx提供了$upstream_cache_status这个变量来显示缓存的状态,我们可以在配置中添加一个http头来显示这一状态,达到类似squid的效果。
location  / {
        proxy_redirect          off;
        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   180;
        proxy_send_timeout      180;
        proxy_read_timeout      180;
        proxy_buffer_size       128k;
        proxy_buffers           4 128k;
        proxy_busy_buffers_size 128k;
        proxy_temp_file_write_size 128k;
        proxy_cache cache;
        proxy_cache_valid 200 304 1h;
        proxy_cache_valid 404 1m;
        proxy_cache_key $uri$is_args$args;
        add_header  Nginx-Cache "$upstream_cache_status";
        proxy_pass http://backend;
    }
  
  
而通过curl或浏览器查看到的header如下:
HTTP/1.1 200 OK
Date: Mon, 22 Apr 2013 02:10:02 GMT
Server: nginx
Content-Type: image/jpeg
Content-Length: 23560
Last-Modified: Thu, 18 Apr 2013 11:05:43 GMT
Nginx-Cache: HIT
Accept-Ranges: bytes
Vary: User-Agent
  
  
$upstream_cache_status包含以下几种状态:
·MISS 未命中,请求被传送到后端
·HIT 缓存命中
·EXPIRED 缓存已经过期请求被传送到后端
·UPDATING 正在更新缓存,将使用旧的应答
·STALE 后端将得到过期的应答
=======================================================================================================================
nginx比较强大,可以针对单个域名请求做出单个连接超时的配置. 可以根据业务的:
 
proxy_connect_timeout :后端服务器连接的超时时间_发起握手等候响应超时时间
proxy_read_timeout:连接成功后,等候后端服务器响应时间_其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间)
proxy_send_timeout :后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据
$upstream_status
前端服务器的响应状态。