Lui*_*aca 1 apache wordpress web-applications nginx
我正在设置Nginx作为服务Wordpress安装的apache2的代理.问题是在根URL url appsrd.devmbs.com上获得重定向循环.当我点击服务器时,我在日志中看到以下12-15次.
127.0.0.1 - - [03/Sep/2012:12:29:25 +0000] "GET /index.php HTTP/1.0" 301 529 "http://appsrd.devmbs.com/wp-admin/options-general.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1"
Run Code Online (Sandbox Code Playgroud)
但/ wp-admin效果很好.没有重定向问题.我尝试删除数据库,虽然数据库不可用,但根显示错误信息建立数据库连接,这很好,因为这是预期的行为,但没有重定向问题.然后我再次创建了DB并运行了wordpress设置,当一切都完成后,重定向问题又回来了.
Beloe我的nginx服务器conf:
server {
listen 80 default_server;
server_name appsrd.devmbs.com;
root /home/ubuntu/projecs/APPS-RD;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/ubuntu/projects/APPS-RD;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
proxy_pass http://127.0.0.1:3000;
proxy_buffering on;
proxy_buffers 12 12k;
proxy_set_header Host $host;
}
}
Run Code Online (Sandbox Code Playgroud)
网址为appsrd.devmbs.com,appsrd.devmbs.com/wp-admin正常.
任何人都知道可能会发生什么?
对于任何可能遇到此问题的未来人...
出于我的实验目的,我希望Nginx显示任何和所有现有的非PHP文件,并将PHP文件和动态URL代理到Apache for WordPress来完成它的工作.我还希望WordPress能够使用正常的.htaccess文件.
Luis原始发布的初始代码的问题是Nginx明确声明使用index.php,因为它是WordPress环境中唯一的索引.结果是,当你去"domain.com/"时,Nginx将其发送给Apache,看起来就像"domain.com/index.php".当WordPress收到"domain.com/index.php"时,它会自动缩短并重定向到"domain.com/"; 因此你最终得到了那个循环.
适用于WordPress环境的最佳工作(针对确定的)也是将任何目录发送到WordPress.此设置的缺点是它将忽略任何不是index.php的索引.
server {
listen 80;
server_name domain.com;
root /path/to/web/root/;
# Proxy anything that isn't a file.
location / {
try_files $uri @apache;
}
# Proxy directories (This fixes the loop)
# This will kill any other indexes like index.html if they're not explicitly used in the URL.
location ~[^?]*/$ {
include proxy_apache;
}
# Proxy any .php file.
location ~ \.php$ {
include proxy_apache;
}
# Proxy to apache, used by location / {...}
location @apache {
include proxy_apache;
}
# this will prevent files like .htaccess .htpassword .secret etc from being served
# You can remove the log directives if you wish to
# log any attempts at a client trying to access a hidden file
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
Run Code Online (Sandbox Code Playgroud)
如果您注意到名为*proxy_apache*的文件的内容,其中包括多次,
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
Run Code Online (Sandbox Code Playgroud)
同样,不一定是最实用的解决方案,但它确实具有以下优点:
| 归档时间: |
|
| 查看次数: |
3441 次 |
| 最近记录: |