我相信我已经正确设置了nginx来caching代理到PHP-FPM的所有请求,但是它不起作用。 以下是/etc/nginx/nginx.conf中的“http”位: http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; proxy_cache_path /var/cache/nginx/static levels=1:2 keys_zone=static:20m; include /etc/nginx/conf.d/*.conf; keepalive_timeout 30; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; gzip on; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_comp_level 5; gzip_vary on; gzip_proxied […]
更新:我find的临时解决scheme是只redirect到https的所有http请求。 我一直在努力在我的网站上设置SSL。 这就像在一个Rails上。 我使用nginx与独angular兽。 我从GoDaddy购买了证书。 然后,我按照本文档的说明进行设置并在/etc/nginx/ssl生成CSR。 然后,我复制了生成的.csr文件的文本,并用它从GoDaddy发出证书。 证书颁发后,我下载了在GoDaddy上生成的密钥包,并遵循本文档中的指示。 然后configuration我的/etc/nginx/sites-enabled/mysite.conf文件: (我在服务器{…}下添加了以下几行 listen 443; ssl on; ssl_certificate /etc/nginx/ssl/mysite.crt; ssl_certificate_key /etc/nginx/ssl/mysite.key; (我更换了listen 80 default; listen 443; ) 然后,我重新启动服务器,并使HTTPS://www.example.com正常工作。 https是绿色的,显示证书没问题。 但是,当我浏览到HTTP://www.example.com我得到一个错误:502错误的网关 – nginx。 我不确定是什么原因造成的。 任何线索? 如果你需要任何其他信息让我知道,我会张贴他们。 我的网站configuration: /etc/nginx/sites-enabled/example.conf upstream example { server unix:/u/app/example/shared/.sock fail_timeout=0; } server { listen 80; server_name www.example.com; root /u/app/example/current/public/; access_log /u/app/example/shared/log/nginx.access.log; error_log /u/app/example/shared/log/nginx.error.log; client_max_body_size 20M; […]
我在ubuntu 14.04上通过apt-get install nginx 。 因此,默认设置包括目录/etc/nginx/conf.d/configuration include /etc/nginx/conf.d/*.conf; 在我的conf.d文件夹中,我有以下两个文件(site1.conf和site2.conf) server { listen 80; location /site1/ { proxy_pass http://127.0.0.1:3000/; } } 和 server { listen 80; location /site2/ { proxy_pass http://127.0.0.1:3001/; } } 当我访问http://xxxx/site1/ ,如预期的那样,我从端口3000上运行服务器得到响应。 当我访问http://xxxx/site2/ ,但是,我得到了404。在错误日志中,它说 2014/07/29 09:37:51 [error] 23060#0: *9 "/usr/share/nginx/html/site2/index.html" is not found (2: No such file or directory), client: 5.57.55.92, server: , […]
我有一台使用nginx web服务器的centOS机器。 在我的应用程序(php)中,我使用cURL来获取远程文件,然后将其发送到视图: $cache_expire = 60*60*24*365; header("Pragma: public"); header("Cache-Control: maxage=". $cache_expire); header('Expires: ' . gmdate('D, d MYH:i:s', time() + $cache_expire).' GMT'); $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $REMOTE-FILE-URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $img = curl_exec($ch); curl_close($ch); echo $img; 我想知道,cURL需要下载文件到我的服务器的某个地方的tmp / cache文件夹吗? 这个文件夹在哪里? 稍后删除文件,或者我必须在一段时间内清理文件夹?
我刚刚在我的Ubuntu 14.04 LTS 64位服务器上安装了Nginx 1.6.0,MySQL,PHP-FPM 5.5.9和phpMyAdmin。 当我去domain.tld / phpmyadmin我最终在一个空白页面,但是当我查看源代码,我可以看到HTMLlogin表单,JavaScript和其他一切,虽然页面是空白的。 我遵循这个指南和普通的PHP脚本工作。 一个简单的PHP脚本,回声“你好”完美的作品。 在/var/log/nginx/error.log或access.log中没有错误。 这是我的nginxconfiguration: server { listen 8081 default_server; #listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to […]
我想设置我的nginx conf,以便我可以为我的多个Django项目提供相关文件。 最终,我希望每个应用程序在www.example.com/app1,www.example.com/app2等都可用。它们都从位于各自项目根目录中的“静态文件”目录提供静态文件。 项目结构: Home Ubuntu Web www.example.com ref logs app app1 app1 static bower_components templatetags app1_project templates static-files app2 app2 static templates templatetags app2_project static-files app3 tests templates static-files static app3_project app3 venv 当我使用下面的conf时,服务我在/ static / location中指定的应用程序的静态文件没有问题。 我也可以访问在他们的位置find的不同的应用程序。 但是,我不知道如何同时为所有的应用程序提供所有的静态文件。 我已经研究了使用“try_files”命令的静态位置,但不知道如何看它是否工作。 Nginx Conf – 只为一个应用程序提供静态文件: server { listen 80; server_name example.com; server_name www.example.com; access_log /home/ubuntu/web/www.example.com/logs/access.log; […]
我正尝试在我的Nginx服务器上密码保护WordPresslogin页面。 当我导航到http://www.example.com/wp-login.php时 ,会出现用户名和密码的“需要validation”提示(不是WordPresslogin页面)。 但是,当我input正确的凭证时,它会下载PHP源代码(wp-login.php),而不是显示WordPresslogin页面。 我的htpasswd文件的权限设置为644。 以下是我的网站configuration文件的服务器块中有问题的指令: location ^~ /wp-login.php { auth_basic "Restricted Area"; auth_basic_user_file htpasswd; } 或者,这里是我的configuration文件的全部内容(包括上面四行): server { listen *:80; server_name domain.com www.domain.com; root /var/www/domain.com/web; index index.html index.htm index.php index.cgi index.pl index.xhtml; error_log /var/log/ispconfig/httpd/domain.com/error.log; access_log /var/log/ispconfig/httpd/domain.com/access.log combine$ location ~ /\. { deny all; access_log off; log_not_found off; } location = /favicon.ico { log_not_found off; […]
我刚从源码安装Nginx 1.6.1,但似乎没有正确安装。 Nginx正在运行,如果我service nginx status但是当我做nginx -v它输出命令找不到。 正常的HTML页面显示正常,错误日志中没有错误。 我在AWS Ec2 linux AMI上。 这是我的/etc/init.d/nginx脚本 #!/bin/sh # # nginx – this script starts and stops the nginx daemon # # chkconfig: – 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: […]
我正在尝试学习如何configurationNginx代理。 所有来自外部(www.external.com)的请求都应该到内部服务器10.10.10.16:2080,除了www.external.com/nagios请求,应该去10.10.10.18。 我的位置块如下所示: location ~* / { proxy_buffers 16 4k; proxy_buffer_size 2k; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Accept-Encoding ""; proxy_pass http://10.10.10.16:2080; } # # nagios server location ~* /nagios/ { proxy_buffers 16 4k; proxy_buffer_size 2k; proxy_buffering off; # proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header Accept-Encoding ""; proxy_pass http://10.10.10.18; […]
我有一个Nginx服务器(1.6),在我的本地服务器上有PHP-FPM。 我有我的“/ var / www /”文件夹中的多个webapps,如site01,site02 … 我的应用程序使用CodeIgniter。 我想在/ var / www / site01调用默认位置,并调用/ var / www / site02当我去: http://server/site02. 这里是我的nginx的default.conf: 服务器{听80; server_name localhost; access_logclosures; client_body_buffer_size 1M; proxy_max_temp_file_size 0; disable_symlinks off; # Site 01 location / { root /var/www/site01; index index.html index.php index.htm; try_files $uri $uri/ /index.php; location = /index.php { fastcgi_pass 127.0.0.1:9000; fastcgi_read_timeout 10000; […]