我有一台debian机器,我在其上安装了用于我的Web服务器工作进程的nginx。 但是我们只需要在/etc/nginx/sites-enabled/下find默认的nginxconfiguration中的wordpress。 /etc/nginx/sites-enabled/wordpress.com /etc/nginx/sites-enabled/drupal.com 我可以知道单个debian机器下的这两个网站的样本nginxconfiguration。
我有.php文件在多个目录(/ jobs / marketing /,/ jobs / content / etc)需要干净地映射到/jobs/name-of-file.php。 例如点击url: /jobs/digital-marketing 需要映射到: /jobs/marketing/digital-marketing.php 假设每个php文件的文件名在目录中是唯一的是安全的。 我目前的nginx设置如下: location /jobs { expires max; add_header Cache-Control public; add_header Pragma public; rewrite ^/jobs[\/]?$ /marketing/jobs.php last; location ~* ^/jobs/([\-a-z0-9]*)$ { try_files /marketing/jobs/engineering/$1.php /marketing/jobs/marketing/$1.php /marketing/jobs/business-development/$1.php /marketing/jobs/content/$1.php; } location ~ ^/.+\.php($|/) { fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param PATH_TRANSLATED […]
我看到很多人configuration一个nginx服务器有多个symfony2应用程序有问题。 然而,没有人想要和我一样的问题,也有同样的问题。 我想要做的是在同一个域上有多个应用程序。 一个主要的应用程序将直接回答这个域,其他的将会在别名子目录下。 用一个模式: http://mydomain/ -> main app http://mydomain/subdir1 -> another app http://mydomain/subdir2 -> yet another app 我自己试图做到这一点,主要的应用程序完美的作品。 但子目录大部分时间被主应用程序拦截,这会引发404错误。当我尝试在子目录的URL(如http://mydomain/subdir1/app.php/my/route )中添加app.php时, ,服务器返回404。 这是我到现在为止所做的: server { listen 80; server_name mydomain; root /server/www/main-app/web; location / { # try to serve file directly, fallback to app.php try_files $uri /app.php$is_args$args; # PROD location ~ ^/app\.php(/|$) { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info […]
有无数的教程检查cookie是否存在,并包含我的内容,在这种情况下foobar 。 假设mycookie是我想要设置的cookie,我如何执行以下操作。 if ($cookie_mycookie does not equal "foobar") { return 401; } 我尝试了以下无济于事。 if (!$http_mycookie ~* "foorbar" ) { return 401; } 谢谢!
我试图设置nginxcaching静态文件,如图像,CSS和JS。 这是我的conf。 server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /var/www/site; index index.html index.htm; } location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 […]
我有我的phpmyadmin安装程序 location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location /phpMyAdmin { rewrite ^/* /phpmyadmin last; } 我正在寻找更改文件夹名称,以便我可以通过/安全访问phpmyadmin location /secure { root /usr/share/; index index.php index.html index.htm; […]
我试过逃避(而不是转义),有(和没有)单引号双qoutes,但我总是在404页面上。 这甚至有可能吗? 我试图寻找它,但登陆的https://serverfault.com/questions/361915/how-can-i-make-nginx-recognise-directories-with-spaces-in-its-name但我已经试过,并没有工作。 如果这我只是我,那么请certificate给我:)
我想在这里按照这个例子 – https://gist.github.com/morhekil/1ff0e902ed4de2adcb7a#file-nginx-conf但获取错误 – "set" directive is not allowed here 我究竟做错了什么? 请注意,我正在使用openresty并调用nginx as- nginx -p `pwd`/ -c conf/nginx.conf 我的nginx.conf的上下文完全匹配https://gist.github.com/morhekil/1ff0e902ed4de2adcb7a#file-nginx-conf 如果我将setvariables移动到server部分,我不再会得到这个错误,而是一个新的错误 – nginx: [emerg] unknown "resp_body" variable
我正在使用nginxconfiguration一个非常标准的networking服务器。 服务器按预期工作,但是,我想了解一个小的configuration细节。 我目前的configuration是: index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php?q=$uri; } location ~ \.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } 有了这个configuration,如果我访问: http : //myweb.com/wp-content/uploads/2012/10/cropped-bitmap11.png/lol.php我得到了一个404预期。 但是,有了这个configuration: try_files $uri =404; location ~ \.php$ { fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } 我得到一个“拒绝访问”的空白页面。 […]
我做了我以前的研究,但似乎无法find如何正确configurationnginx接受一个子域名。 我目前正确地为mydomain.comconfiguration,但不是analytix.mydomain.com: server { listen 80; server_name *.mydomain.com; access_log /home/ubuntu/virtualenv/mydomain/error/access.log; error_log /home/ubuntu/virtualenv/mydomain/error/error.log warn; connection_pool_size 2048; fastcgi_buffer_size 4K; fastcgi_buffers 64 4k; root /home/ubuntu/virtualenv/mydomain/homelaunch/; location /static/ { alias /home/ubuntu/virtualenv/mydomain/homelaunch/static/; } location / { proxy_pass http://127.0.0.1:8001; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } } server_name声明接受<anythinghere>.mydomain.com这是很好的。 […]