我对nginx世界比较陌生,现在我有一个非常复杂的问题(从我的angular度来看)。 在这里我的场景。 我开发了一个Web应用程序(基于backbone.js的单个页面应用程序)以及我使用Wordpress的内容页面(印记和那些东西)。 我想要达到以下结果:
如果用户点击我的网站(example.com),那么应用程序的index.html应该包含所有JavaScript内容。 如果用户单击页脚中的链接,例如example.com/imprint,则应该加载Wordpress的内容页面。
我实现了通过我的主域example.com访问应用程序,但所有应从Wordpress提供的子页面只显示“文件未find”,nginx.log告诉我:
当读取来自上游的响应报头,客户端:91.114.231.224,服务器:www.example.at,在stderr中发送的FastCGI:“主要脚本未知”请求:“GET / trainer / HTTP / 1.1”,上游:“fastcgi:// unix:/var/run/php5-fpm.sock:”,主机:“www.example.at”
由于应用程序也可以在Facebook上使用,所以也可以在app.example.com下find。 所以我试图代理传递每个请求到example.com的根到app.example.com。 这工作正常,但正如提到的configurationWordpress不会再工作。
这是我目前的configuration文件(在@Pothi Kalimuthu的input之后)
server { server_name www.domain.at domain.at; # other directives, such as index index.html; error_log /var/www/log/error.log debug; root /var/www/temp; location = / { # process the single page apps #proxy_pass http://mdev.domain.at/; # or #try_files $uri $uri/ /index.html; } location /shared { root /var/www/temp/src; } location / { # let's process WordPress here # if WordPress is installed in another location, then alias /var/www/web/; try_files $uri $uri/ /index.php; # process PHP here location ~* ^/(.*\.php)$ { # directives to process PHP fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } }
我尝试了很多,所以请原谅。
你可以给我任何提示如何解决我的问题,例如,如果代理传递函数可能是错误的路要走?
编辑在Pothi Kalimuthu的input后,我设法至less得到我的单页应用程序和wordpress一起工作。
有没有人有一个想法如何configurationnginx得到它的第三个zend框架项目只服务的URL匹配domain.at/trainers/或位置^〜/教练(我猜)?
EDIT2
我为/培训人员添加了位置块,但总是会提供index.html
location /trainers/ { root /var/www/staging/public; #alias /var/www/staging/public; index index.php; try_files $uri $uri/ /index.php$is_args$args; }
更新 :你原来的问题稍微修改应该可能工作。 请尝试以下…
server { server_name domainname.com; # other directives, such as index index.html index.php; root /path/to/apps; location = / { # process the single page apps # proxy_pass http://...; # or # try_files $uri $uri/ /index.html; } location / { # let's process WordPress here # if WordPress is installed in another location, then # alias /path/to/wordpress/; try_files $uri $uri/ /index.php; # process PHP here location ~* ^/(.*\.php)$ { # directives to process PHP } } }
我希望有帮助。