Articles of nginx

Nginx允许/拒绝被忽略的指令,php正在处理

我有一个目录(www / nginx / website1 / private),我不想通过networking浏览器访问,但是依赖于该目录内容的php应用程序必须访问该目录。 我尝试了所有我能想到的,并在这里阅读类似的问题。 没有我已经尝试过的工作。 我努力了: location /private/ { allow 127.0.0.1; deny all; return 404; # do not want to acknowledge existence of files. return 404 } 它不起作用。 如果我直接导​​航到php文件,它将处理php文件 – 我已经通过在php文件中添加一个echo命令来确认。 这是我目前的nginx.conf文件(没有任何失败的尝试)。 我需要添加(以及在哪里)以上述方式阻止访问? 非常感谢你! user www; worker_processes 4; error_log /var/log/nginx/error.log info; events { worker_connections 1024; } http { include mime.types; default_type […]

openssl和keytool在PEM中的冲突

我在ubuntu的nginx服务器上创build了一个自签名证书,如下所示: sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt 用css打开ssl来隐藏crt: openssl x509 -in nginx-selfsigned.crt -out nginx-selfsigned.pem -outform PEM 当我在debian中使用keytool导入这个证书时,导入过程是成功的: sudo keytool -importcert -keystore /certs -storepass changeit -file nginx-selfsigned.pem -alias some alias 但之后,证书不被信任。 为什么导入证书不被信任? 任何有关这个问题的build议,将不胜感激。

Nginx 403禁止在文件上设置好的权限

我试图使用一个子文件夹来包含我的服务器上的Web应用程序。 例如:example.com/netdata ===> Netdata monitoring example.com/passbolt ====>密码pipe理器等。 为了使事情工作我已经使用这个configuration: #Passbolt server { listen 80 default_server; listen [::]:80 default_server; listen 443 ssl default_server; listen [::]:443 ssl default_server; ssl_certificate /etc/nginx/ssl/cert.pem; ssl_certificate_key /etc/nginx/ssl/key.pem; allow all; root /var/www/html/; server_name passbolt.local; location /passbolt/ { alias /var/www/html/passbolt/app/webroot/; try_files $uri $uri/ /index.php?$args; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; } } } […]

nginx的try_files没有find大目录中的文件(86k文件)

首先,nginxconfiguration: server { listen 443 ssl; server_name example.com; ssl_certificate /example/fullchain.pem; ssl_certificate_key /example/privkey.pem; client_max_body_size 5M; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; location @example { add_header X-Orig-Url $uri; proxy_pass http://example; # the nodes } location ~ "^/assets/uploads/(.*)" { add_header X-Static-Asset $1 always; root /usr/share/nginx/html/; try_files /uploads/$1 @example; } […]

如何将nginx请求代理到tomcatpath?

我有一个域名example.com。 当进入example.com我想代理请求到127.0.0.1:8080/source 我的nginxconfiguration location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:8080; } 这适用于127.0.0.1:8080,但我不能让它代理到/源子目录。 当我改变 proxy_pass http://127.0.0.1:8080/source/; 它不能正常工作。 它redirect到http://127.0.0.1:8080/source/ ,但是js和css文件path是/source/js/ *.js和/source/css/ *.css ,其他资源文件是/source/* 。 例如,当浏览器加载html时,它会尝试查找/source/js/ *.js ,因为我redirect到http://127.0.0.1:8080/source/ ,最终path是http://127.0.0.1:8080/source/source/js/ *.js ,但正确的path是http://127.0.0.1:8080/source/js/ *.js 我只是想当我进入example.com ,它将redirect到http://127.0.0.1:8080/source/ ,或者redirect到example.com/source也没关系。

NGINX:如何使用url中的参数redirect域名?

我一直在尝试使用URL重写将URLredirect到另一个域。 以下是我的nginx.conf文件: worker_processes 1; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; server { listen 8070; server_name www.example.com; rewrite ^/v1/([0-9]+).html http://www.example.com/v1?exid=$1; location ~ /v1/([0-9]+) { return 301 http://dev.example1.com/v1?exid==$1; } } } 我一直在尝试很长一段时间,但我仍然无法find合适的解决scheme。 注:我没有得到任何错误,如果我尝试以上,但预期的redirect不会发生。 我希望将此urlredirect到http://example.com/v1/68740.html —至—> http://dev.example1.com/v1?exid=68740 。 提前致谢。

Nginx日志:客户端closures连接,同时握手SSL

CentOS 7.2 Nginx 1.13.0 PHP 7.1.4 我的错误日志有很多下面的行 2017/05/16 06:32:05 [info] 18838#18838: *10061 client closed connection while SSL handshaking, client: 120.188.122.190, server: 0.0.0.0:443 这个日志的含义究竟是什么? 谢谢

NGINXredirect而不是代理

有这样几个问题,但最相似的是没有答案,其余的都是混杂因素。 以前的工作很好的nginx的部署是redirect而不是代理。 nginx.conf的相关部分看起来像这样; location /timesheets/ { gzip on; gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_proxied any; gzip_min_length 1000; gzip_comp_level 2; gzip_http_version 1.0; gzip_buffers 16 8k; gunzip on; gzip_static on; # Disable for IE < 6 because there are some known problems gzip_disable "MSIE [1-6].(?!.*SV1)"; # Add a vary header for downstream proxies […]

将.htaccess转换为nginx。 重写不应该如此

我无法将.htaccess转换为nginxconfiguration。 我一直在尝试使用在线转换工具。 .htaccess转换如下: RewriteEngine on RewriteCond %{REQUEST_URI} !/public RewriteCond %{REQUEST_URI} !/index.php RewriteRule ^(.*)$ index.php/?params=$1 [NC] 我一直在尝试使用下面的nginxconfiguration: location / { rewrite ^(.*)$ index.php/?params=$1; } 这只是不正常的工作。 它也允许访问这个目录中的其他文件。 我只想要index.php可用。 甚至需要使用.htaccess规则。 在生产服务器上不能安装apache / httpd。 而且我不想浪费资源在docker中运行apache。

Nginx和fcgiwrap,增量输出问题

当我在Apache下运行一个cgi脚本时,任何输出都会快速发送到客户端。 但是,当我用fcgiwrap在nginx下运行它时,似乎没有任何东西被发送到客户端,直到脚本完成或产生大量的输出。 以下脚本可以看到这种行为。 #!/bin/bash echo "Content-type: text/html" echo while : do echo this is a test. sleep 5 done 在apache下,客户端将每5秒钟获取一些数据。 在nginx和fcgiwrap下,我没有得到任何数据和网关超时。 nginx和fcgiwrap是来自Debian Jessie的软件包。 版本1.1.0-5和1.6.2-5 + deb8u4 所以问题 有谁知道这是什么负责这种行为? nginx本身? fcgiwrap? 都? 是否可以通过configuration来修复? 如果这是一个fcgiwrap问题,有没有替代cgi包装可用,不会遇到问题?