Articles of nginx

Nginx的:过期头不工作

我遇到expires标题字段的问题。 下面的nginx规则给了我这个头(没有过期的头)。 想法为什么到期的标题不被传递? 头文件为:/css/v1/afile.css HTTP/1.1 200 OK Server: nginx Date: Sat, 14 Sep 2013 07:29:59 GMT Content-Type: text/css Content-Length: 12548 Last-Modified: Sat, 11 May 2013 11:05:51 GMT Connection: keep-alive Accept-Ranges: bytes Nginxconfiguration: server { listen 80 default_server; server_name _; root /var/www/apps/myapp/public/app/webroot; index index.php index.html index.htm; server_tokens off; access_log /var/www/apps/myapp/logs/access.log; error_log /var/www/apps/myapp/logs/error.log; client_max_body_size 20M; rewrite_log on; […]

为什么Nginx在根域之后接受任何URL值?

第一次设置Nginx,我的目标是让example.com带有一个静态的'index.html'页面,并以最低限度的configuration提供服务。 我也想删除www子域。 这里是我的网站 – 可用的服务器块: server { server_name www.example.com; return 301 $scheme://example.com$request_uri; } server { server_name example.com; root /var/www/example.com/; index index.html index.htm; location / { try_files $uri $uri/ /index.html; } } 如果我使用www.example.com或example.com,他们工作正常,www自动下降。 我的问题是我可以input任何东西后example.com和index.html页面仍然加载,如example.com/ABC或example.com/12345。 这些网页不存在,为什么url被接受? 我希望除域根以外的任何URL都可以返回404页面。 这可能是一个非常简单的问题,但我试着在这里和文档中search,到目前为止我没有提到任何东西。

如何设置nginx和fastcgi在子文件夹中运行Laravel?

我在单个域的子文件夹(社交networking应用程序,需要https,单个证书)下设置多个Laravel应用程序。 无法弄清楚如何编写nginxconfiguration将HTTP请求映射到/app1/到/var/www/other_folder/public/下的Laravel安装。 这是最新的configurationtesting迭代。 debugginglogging省略。 Laravel根位置/ app1 / works,但是路由映射( /app1/api/method/ )不会。 请帮忙,如何debuggingnginx如何逐步处理请求(debugging日志是不是说明),或者给我一个提示如何映射/app1/…子文件夹到Laravel的index.php 。 server { listen 80; server_name apps.mydomain.com; root /var/www/apps.mydomain.com/docs; location / { index index.html index.php; } location /app1 { alias /var/www/other_folder/public; index index.php index.html; try_files $uri $uri/ /app1/index.php$is_args$args /app1/index.php?$query_string; } location ~ /app1/.+\.php$ { rewrite ^/app1/(.*)$ /$1 break; include /etc/nginx/fastcgi.conf; fastcgi_param SCRIPT_FILENAME /var/www/other_folder/public$fastcgi_script_name; fastcgi_index […]

当原始请求通过https进行时,位置标头中的http

我目前在我们的生产环境中实现了https ,但是我正在为这个小东西挠头。 SSL在负载均衡器中终止,我们的堆栈中的stream程基本上是这样的: 生产 :浏览器< – https – >负载均衡器< – http – > Apache < – http – >负载均衡器< – http – > Tomcat testing :浏览器< – https – > nginx < – http – >负载均衡器< – http – > Tomcat 当我通过HTTPS访问我们的login页面时: 请求标头 POST /login/form HTTP/1.1 Host: www.example.org Connection: keep-alive Content-Length: 74 Cache-Control: max-age=0 Origin: […]

supervisord后面的nginx的inet_http_server

我们有在127.0.0.1:9001运行的supervisord [inet_http_server] 。 当我们试图把它放在nginx的后面 – supervisord logtail停止工作。 Supervisord设置: [inet_http_server] port = 127.0.0.1:9001 Nginx设置: server { listen 80; server_name server.com; location / { proxy_pass http://127.0.0.1:9001/; } } 在哪里挖? (停止|开始|重新启动)命令工作,只有tail命令不起作用。

Nginx:拒绝脚本运行在目录及其所有子目录中

说我的网站允许用户创build目录以及上传到一个名为“/ uploads”的目录,如下所示: /上传/ user_created_folder_1 /上传/ user_created_folder_2 /上传/ user_created_folder_3 … 等等等等 如何防止在“/ uploads” 及其所有子目录中执行任何潜在的恶意脚本? 服务器块中的以下代码是否正确? location /uploads/.*.(php|pl|py|jsp|asp|sh|cgi)$ { return 403; error_page 403 403.html; } 非常感谢!

哪个Nginx和哪个configuration文件被使用

我正在尝试为Nginx安装Phusion Passenger模块。 在/usr/sbin/nginx安装了Nginx。 安装程序gem下载了Nginx源代码,并将其与Passenger支持编译到/opt/nginx/sbin/nginx 。 我把这个文件复制到/usr/sbin/nginx 。 所以目前我不确定哪个Nginx正在运行,以及我应该编辑哪个configuration文件。 有什么方法可以确定实际使用的Nginx的位置以及它使用哪个configuration文件?

nginx作为ssl反向代理的wildfly

我正在尝试设置nginx为wildfly 8.0.0.Final的反向代理。 我的HTTPSredirectconfiguration文件的一部分: location /console { include conf.d/proxy.conf; proxy_pass http://127.0.0.1:9990/console; proxy_redirect http://127.0.0.1:9990/console https://XYWZ/console; } … similar location for… /management /logout /error … location / { include conf.d/proxy.conf; proxy_pass http://127.0.0.1:8080/; } proxy.conf: proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; add_header Front-End-Https on; 问题是 – 当我login到/控制台时,我得到错误消息: 访问被拒绝:没有足够的权限来访问这个接口。 我什至不知道这是什么原因造成的。 任何帮助表示赞赏!

使用外部文件映射旧到新的URL – configuration无效

我正在将一个旧网站移到一个新的基于nginx的主机上。 为了保存URL(完全改变),我有一个文件列出了映射。 我想用它与地图模块 。 里面的/etc/nginx/nginx.conf http{ … }我指的是PERL和小写函数: #Include PERL and have a function for lowercasing the incoming URL perl_modules perl/lib; # function to lowercase incoming strings like the URL perl_set $uri_lowercase 'sub { my $r = shift; my $uri = $r->uri; $uri = lc($uri); return $uri; }'; 我的站点configuration文件在/etc/nginx/sites-enabled/notessensei (Thx Alexey指出)如下所示: server { listen www.notessensei.com:80; […]

Nginx的HTTPS www到非wwwredirect问题

我有一些问题从HTTPS wwwredirect到HTTPS非www与我的nginxconfiguration。 我遵循( 删除“www”和nginxredirect到“https” )提供的指导。 现在下面的工作: http://www.redemfit.com – > https://redemfit.com http://redemfit.com – > https://redemfit.com https://redemfit.com 但是这不是: https://www.redemfit.com – > https://redemfit.com 我最终得到“欢迎使用nginx!” 页。 我在/sites-enabled没有任何其他的nginxconfiguration文件。 任何想法,为什么它可能会这样做? 我的configuration文件如下。 upstream redemfit { server unix:/srv/redemfit/run/gunicorn.sock fail_timeout=0; } server { listen 80; server_name www.redemfit.com redemfit.com; rewrite ^ https://redemfit.com$request_uri? permanent; } server { listen 443; ssl on; ssl_certificate /etc/ssl/private/redemfit-bundle.crt; ssl_certificate_key /etc/ssl/private/redemfit.key; ssl_protocols […]