Articles of nginx

Nginxredirect没有被使用

我有一个nginx.conf文件,看起来像这样: http { server { listen 80; server_name myapp.org; return 301 http://www.myapp.org$request_uri; } server { listen 80; server_name www.myapp.org; passenger_enabled on; root /var/www/myapp/current/public; } } 这似乎是这个网站和其他人build议的格式,但是当我去myapp.org,我只是从nginx得到这个消息: 欢迎来到nginx! 如果你看到这个页面,nginx web服务器已经成功安装并正常工作。 需要进一步的configuration。 有关在线文档和支持,请参阅nginx.org。 商业支持可在nginx.com上find。 感谢您使用nginx。 虽然如果我去www.myapp.org,那么一切都按预期工作。 为什么不redirect? 更新: nginx.conf: user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # […]

proxy_pass到指定的服务器端口和目录

我希望mysite.com/*显示来自127.0.0.1:8080/dir/*内容。 我现在有1:1 mysite.com/*到127.0.0.1:8080/* 。 sites-enabled/mysite.com.conf : server { listen 80; server_name mysite.com location / { proxy_pass 127.0.0.1:8080; } } 我尝试了几个咒语无济于事。 从这里开始,我不确定是否尝试设置root ,使用rewrite ,使用proxy_pass ,使用proxy_pass其他方法,或者完全使用proxy_pass 。 我只是想把一个目录硬塞进我的proxy_pass服务器,结果比预期的要困难得多。

如何在生产服务器上安装nginx-upload-module?

我的nginx服务器是通过以下方法安装的: sudo add-apt-repository ppa:nginx/stable sudo apt-get update && sudo apt-get install nginx 现在我需要https://github.com/vkholodkov/nginx-upload-module/tree/2.2模块来处理图片在我的服务器上传。 怎么能把这个模块添加到工作的nginx生产服务器上?

我怎样才能让Nginx听所有的主机名称,而不是特定的?

这是我的/etc/nginx/nginx.conf文件的一部分。 (我稍微修改了一下,以便不公开实际的IP地址或DNS条目,但你明白了。) server { listen 80; server_name ec2-52-1-2-3.compute-1.amazonaws.com; location / { proxy_pass http://thumbor; } } server { listen 80; server_name 52.1.2.3; location / { proxy_pass http://thumbor; } } 根据本指南 ,我还有一个thumbor的upstream部分。 这工作; 我可以通过http://ec2-52-1-2-3.compute-1.amazonaws.com/或通过http://52.1.2.3/访问它… 不过,我觉得它现在的设置方式有点脆弱。 如果IP地址改变怎么办? 或者如果DNS条目改变了呢? 我宁愿如果它只是响应80端口上的所有请求,而不pipe主机名。 所以我自然而然地尝试这样做: server { listen 80; location / { proxy_pass http://thumbor; } } 正如你可以看到我所做的一样,把它分成了一个单独的server部分,而不是两个,我从该部分删除了server_namevariables。 但不是像我希望的那样回应所有的请求,它不再有任何回应。 它会在404上的一切。 我如何设置一个通用服务器侦听器,就像我在这里描述的那样?

无法用Nginx打开JPEG文件

我正在提供资源的静态页面。 不幸的是,我无法打开图像,而JS和CSS文件正在通过相当好。 尝试访问文件时,我只收到403 (Forbidden) 。 目录hiarachy: /var/www/servers/new.test.com index.html static/ img/ css/ js/ configuration: server { listen 80; server_name area1.test.com; access_log /var/log/nginx/new_test.access.log; error_log /var/log/nginx/new_test.error.log; root /var/www/servers/new.test.com; index index.html index.htm index.php; charset utf-8; location / { try_files $uri $uri/ =404; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { expires 1m; access_log off; add_header […]

Nginx是否保持连接打开,当它进行负载平衡?

我有一个单一的Nginx服务器负载平衡到几个上游服务器。 当请求进入时会发生什么? 负载均衡器是否保持连接打开并等待来自上游服务器的答复? 还是只是将请求传递给上游服务器并“closures”连接? 如果负载均衡器保持连接处于打开状态,直到请求处理完毕,这意味着负载均衡器是我系统中的瓶颈,增加上游服务器的数量并不重要。

Nginx恢复到sslv3

我使用nginx作为反向代理,我试图closuressslv3的支持。 我在这里和其他各种网站上都find了各种答案。 他们都build议我所需要做的就是在我的nginx.conf中添加如下的默认http块 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS:!RC4"; ssl_prefer_server_ciphers on; 我已经完成了,甚至尝试从https://cipherli.st/这个完整的configuration ssl_ciphers "AES128+EECDH:AES128+EDH"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; ssl_session_tickets off; # Requires nginx >= 1.5.9 ssl_stapling on; # Requires nginx >= 1.3.7 ssl_stapling_verify on; # Requires nginx => 1.3.7 resolver […]

Fedora FastCGI上的nginx无法正常工作

我正在Fedora服务器22上运行nginx,而fastcgi脚本不能正常工作。 在http://panel.minefight.org/下input任何login数据,它不会加载密码失败或成功的网站。 其他login表单也会发生同样的情况。 服务器没有redirect用户,我不知道如何解决这个问题。 我希望这个例子很容易理解。 testing页面说,fastcgi正在运行,并与nginx连接。 php-fpm.conf : upstream php-fpm { server unix:/run/php-fpm/www.sock; } php.conf : index index.php index.html index.htm; location ~ \.php$ { try_files $uri =404; fastcgi_intercept_errors on; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php-fpm; } 错误日志包含以下内容(当试图logingamepanel时): 2015/05/30 22:15:57 [error] 1911#0: *1 FastCGI sent in stderr: "PHP message: PHP Deprecated: mysql_connect(): The […]

NGINX – 有条件地允许或拒绝IP

是否可以在NGINX中有条件地允许或拒绝IP? 这是不允许的。 if($example){ deny all; } if ($example2){ allow all; }

不能用php-fpm增加nginx的超时时间

我们的nginx拒绝增加60秒默认值的请求超时。 我已经设置了下面的参数,但是服务器在60秒后仍然给我504: fastcgi_connect_timeout 300s; fastcgi_send_timeout 300s; fastcgi_read_timeout 300s; proxy_connect_timeout 300s; proxy_read_timeout 300s; client_header_timeout 300s; client_max_body_size 200m; client_body_timeout 300s; send_timeout 300s; 有趣的是,将值设置为30秒,30秒后请求超时。 php-fpm中的request_terminate_timeout也被设置为300秒。 我必须设置哪些参数才能超过60秒?