我尝试了很多方法,并坚持使用它。 我编辑/etc/nginx/nginx.conf并编写这些行。 location /home/user/domains/example.com/public_html/lockfolder/ { auth_basic "Restricted"; auth_basic_user_file /home/user/domains/example.com/.htpasswd; } 我使用crypt(3)encryption通过命令mkpasswd创build密码。 然后我用给定的程序user:encryptedpasswd在.htpasswd 。 但事情并不如说。 让我知道如果有人知道我可以如何完全configuration我的目的! 我也用/etc/init.d/nginx reload加载我的nginx
我想在nginx的http上下文中设置一个variables,所以它适用于我所有的服务器。 但是,只有服务器和位置支持“if”。 我怎样才能在http上下文中设置一个variables,这将影响所有的服务器? 可能lua模块能够帮助(虽然我宁愿有一个纯粹的nginx解决scheme)。 如果是这样,请举个例子。 我只是想设置下面的variables,所以它适用于所有的服务器: # only allow gzip encoding. For all other cases, use identity (uncompressed) if ($http_accept_encoding ~* "gzip") { set $sanitised_accept_encoding "gzip"; } if ($http_accept_encoding != "gzip") { set $sanitised_accept_encoding ""; }
我正在尝试将所有HTTP通信redirect到HTTPS。 我使用的Web服务器是nginx。 这是我用来做redirect的服务器块。 server { listen 80; rewrite ^ https://$server_name$request_uri? permanent; } 这成功地将URLredirect到http://localhost到https://localhost 。 但是,对于像http://localhost/table/这样的URL,我将redirect到https://table ,这是不正确的。 我希望它重新指向https://localhost/table/ 任何帮助将非常感激。 更新:似乎重写scheme有一个跟踪斜线问题。 例如, http://localhost/table被正确redirect,但http://localhost/table/不是。
我试图构build一个rails应用程序来上传大型的video文件,这将被承载在s3.amazonaws.com服务器,它与小文件工作正常,但给大的文件(大约30MB)413请求实体太大的错误。 我改变了我的nginxconfiguration文件,并增加了client_max_body_size到4G。 依然不起作用。 有谁能够帮助我 ?
我正在使用Nginx + PHP-FPM来运行一个基于WordPress的网站。 我有一个URL应该返回dynamic生成的JSON数据用于DataTables jQuery插件。 数据正确返回,但返回码为404。我认为这是一个Nginx的configuration问题,但我一直无法弄清楚为什么。 脚本“getTable.php”在当前使用Apache的站点的生产版本上正常工作。 任何人都知道我怎么能得到这个Nginx的工作? url: http : //dev.iloveskydiving.org/wp-content/plugins/ils-workflow/lib/getTable.php 服务器:CentOS 6 + Varnish(caching禁用开发)+ Nginx + PHP-FPM + WordPress + W3 Total Cache Nginxconfiguration: server { # Server Parameters listen 127.0.0.1:8082; server_name dev.iloveskydiving.org; root /var/www/dev.iloveskydiving.org/html; access_log /var/www/dev.iloveskydiving.org/logs/access.log main; error_log /var/www/dev.iloveskydiving.org/logs/error.log error; index index.php; # Rewrite minified CSS and JS files location ~* \.(css|js) […]
有一个问题,当我尝试访问https://betterexaminations.ie ,我得到连接拒绝,但当我尝试的IP,它工作正常,(https://)46.137.41.29。 任何想法可能是什么问题? 在这里我的nginxconfiguration: worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { passenger_root /var/lib/gems/1.8/gems/passenger-3.0.12; passenger_ruby /usr/bin/ruby1.8; server { listen 443; server_name betterexaminations.ie; root /var/rails/papers/public/; passenger_enabled on; ssl on; ssl_certificate /var/rails/papers/certs/csr/thawte/certificate.bundle.cert; ssl_certificate_key /var/rails/papers/certs/csr/www.betterexaminations.ie.key; ssl_verify_depth 3; } server { listen 80; server_name betterexaminations.ie; root /var/rails/papers/public/; passenger_enabled […]
我有一个由nginx背后的WSGI服务器。 假设我将WSGI实例closures以进行维护/更新,nginx是否有一种很好的方式来自动向指定的HTML文件提供对该应用程序的任何请求?
我试图为我的Nginx服务器上运行的网站设置一个友好的URL,但由于某种原因,url正在被redirect,而不是被重写。 例如,如果用户访问mydomain.com/aboutme/我想mydomain.com/aboutme/留在地址栏中,但要从mydomain.com/aboutme.php 在我的Nginx站点configuration中,我有以下几个(简单的例子,为了简单起见,一些东西被砍掉): server { listen 1.2.3.4:80; server_name www.mydomain.com; location / { rewrite ^/aboutus/$ http://www.mydomain.com/aboutus.php permanent; } } 不pipe出于什么原因,Nginx似乎坚持将友好的urlredirect到php文件,但是我想要一个更传统的“重写”(就像我之前在Apache mod_rewrite中所做的一样)。 我可能做错了什么,但是如果我能弄清楚什么的话,我会被诅咒的。
我有一个受密码保护的服务器,在那里存储我希望我的用户只有拥有权限才能访问的文件。 在NGiNXconfiguration我想能够做到这样的事情: proxy_pass http://username:password@domain:80/ 所以用户可以去这个地址: http://img.website.com/bob.jpg 然后在服务器的configuration将指向这个地址: http://username:password@domain:80/bob.jpg 还有一种方法来调用脚本(最好是PHP),看看访问该文件的人是否已login。 我的会话被保存在另一台服务器上(在Redis数据库上),所以如果不能用PHP来做,还有另一种方法吗? 那么如何configuration呢?
如何更新nginx添加模块,而不删除旧的nginx文件/configuration? 我安装了apt-get安装nginx,我试图通过从nginx网站下载tar.gz安装,但它没有任何效果。 我正在使用debian 6.0.2压缩 我会很感激的build议。 最好的祝福