我使用Nginx等设置了4个域名,并有一个html文件夹结构如下: html/site1/ html/site2/ html/site3/ html/site4/ 问题是,当我去123.456.789.012我得到了默认的Nginx页面,我的域名实际上是在123.456.789.012 / site1 /等。这对我来说是有道理的,我知道为什么这样做,所有网站都在子文件夹根。 基本上我想要123.456.789.012redirect到123.456.789.012 / site1 /但没有/ site1 /附件。 这可能没有移动我的文件的site1到根? 是否离开它现在呢? 我无法想象任何人想通过IP浏览我的网站。
我目前在三个Django应用程序(Apache / mod_wsgi)之前使用nginx的proxy_cache进行基于文件的caching。 对于某些位置/ URL,我禁用了proxy_cache,而是在Django应用程序中使用了Memcached(每个视图)。 现在我想知道将nginx指向Memcached是否更有效率。 我在这里读到,nginx可以提供来自Memcached的页面,但Django在为每个视图cachingconfiguration完整页面之后,是否将完整的页面写入Memcached(并根据@cache_page参数设置了到期date)?
我正在Rackspace上设置一个服务器来迁移现有的网站,以便在更改DNS条目之前让所有的东西都能正常工作。 我没有问题让服务器工作在IP地址使用默认设置。 然后,我复制了原始站点可用文件,将其链接到已启用站点的文件中,并将原始index.html复制到新文件夹中。 我将站点可用的根设置为新文件夹,并在文件夹上执行chown -R www-data:www-data , chmod 775和chmod 664 。 之后我重新启动了Nginx。 当我调出该网站的IP地址时,我得到404 Not Found。 这里是网站可用: server { listen [::]:80 default_server; root /var/www/example.com/public/; index index.html index.htm; server_name localhost; location / { try_files $uri $uri/ =404; } }
我基本上是试图实现Apache MultiViews行为,以便我的URL不需要.php扩展名。 就我从其他问题上看到的服务器故障回答,我应该有这个问题sorting,但是在我的nginxconfiguration中显然是错误的。 行为几乎是正确的; 我可以浏览到/path/to/app/和index.php文件被正确parsing 我可以浏览到/path/to/app/function.php文件被正确parsing 我可以浏览到/path/to/app/media/some.jpg并将其作为静态内容提供 如果我浏览到/path/that/doesnt/exist我得到一个404预期 但是,如果我浏览到/path/to/function try_files指令正确地匹配它到function.php但下载它作为一个静态文件。 这里是configuration文件: server { listen 80; server_name app; root /path/to/app; index index.php index.html index.htm; access_log /var/log/nginx/access.log; location / { allow all; try_files $uri $uri/ $uri.php =404; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; } location ~ /\.ht { deny all; } }
我正在使用NGINX在node.js应用程序前面执行粘性会话负载平衡,该应用程序将支持http,ssl和websockets。 如果我想让负载均衡器简单地将请求转发到node.js服务器,并始终让node.js服务器处理任何SSL终止,那么仍然可以使用基于cookie或IP地址的粘性会话吗? 或者我需要在负载平衡器级别进行SSL终止? 如果我需要在LB级执行SSL终止,那么在将请求发送到node.js服务器之前,是否需要重新encryption请求?
我有2个子文件夹,它们在my_url / test1和my_url / test2上打开 location /test1 { index index.html index.php; ## Allow a static html file to be shown first try_files $uri $uri/ /test1 /index.php; expires 30d; ## Assume all files are cachable } location /test2 { index index.html index.php; ## Allow a static html file to be shown first try_files $uri $uri/ /test2/index.php; […]
有没有办法根据主机名在nginx中换出robots.txt文件? 我目前有www.domain.com和backup.domain.com指向相同的nginx服务器,但我不希望谷歌索引backup.domain.com。
我想redirect非SSLstream量到所有子域的SSL。 我想保持子域相同。 我想为staging.foo.com指定一个不同的proxy_pass 。 我现在只有3件事foo.com , www.foo.com和staging.foo.com 。 我想代理将裸域和www传递给localhost 8000.而代理将staging子域传递给localhost 8001。 http://foo.com/ -> https://foo.com/ -proxy-> 127.0.0.1:8000 http://www.foo.com/ -> https://www.foo.com/ -proxy-> 127.0.0.1:8000 http://staging.foo.com/ -> https://staging.foo.com/ -proxy-> 127.0.0.1:8001 随着下面,它看起来像所有stream量到www或staging被redirect到裸露的域名。 我究竟做错了什么? server { listen 80; server_name foo.com www.foo.com staging.foo.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443; server_name foo.com www.foo.com; # … location / { proxy_pass http://127.0.0.1:8000/; […]
我的应用程序通过这样的URL来提供水印图像: http://www.domain.com/watermark/image1234.jpg/thumbnail/ 我想知道如何设置nginx将其识别为静态图像,这样我就可以将Expiry标题放到它们的头部。 到目前为止,我已经尝试在我的nginx网站configuration下面的设置,但不起作用: location ~* \.(png|gif|jpg|jpeg|swf|ico)$ { access_log off; expires 30d; add_header Pragma public; add_header Cache-Control "public"; tcp_nodelay off; break; } 和 location ~* \.(png|gif|jpg|jpeg|swf|ico)\/[a-zA-Z0-9-]\/$ { access_log off; expires 30d; add_header Pragma public; add_header Cache-Control "public"; tcp_nodelay off; break; } 我得到的输出: $curl -I http://www.domain.com/watermark/image1234.jpg/thumbnail/ HTTP/1.1 200 OK Server: nginx Date: Mon, 06 May 2013 […]
我的服务器拥有两个IP 192.168.1.90和192.168.1.99我希望nginx在192.168.1.99和Apache上侦听192.168.1.90我还需要在apache上托pipe多个虚拟主机。 尝试修改apache的ports.conf NameVirtualHost 192.168.1.90:80 Listen 80 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. Listen 443 </IfModule> <IfModule […]