Nginx 反向代理由 Apache 提供的 Drupal 内容

Nginx 反向代理由 Apache 提供的 Drupal 内容

我是 Nginx 的新手,但有兴趣尝试一下。

我现在让 Nginx 监听端口 80,并从 /srv/www 为主要“促销网站”提供静态 html 内容。我还设置了 apache2,以便从同一位置向 localhost:8080 提供内容。在该位置下,我有一个名为 beta 的文件夹,其中包含我想使用 Apache 而不是 Nginx 提供的 Drupal 安装。

我已成功配置 Nginx,以便 Apache 可以处理发往 example.com/beta 的请求,并且文件在浏览器中可以正确显示,但 Drupal 相关的 php 文件除外。info.php( <?php phpinfo(); ?>) 也可以正常工作。对于任何与 Drupal 相关的 php 文件,我都会收到标准 500 错误。

以下是 apache 和 nginx 的配置文件:

阿帕奇:

<VirtualHost 127.0.0.1:8080>
    ServerAdmin webmaster@localhost

    DocumentRoot /srv/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /srv/www>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    AddType application/x-httpd-php .php

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

Nginx的:

server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/www;
    index index.html index.php index.htm;

    # Make site accessible from http://localhost/
    server_name example.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /index.html;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            deny all;
    }

  #THIS BIT IS FOR DRUPAL
    location ~ ^/beta {
            proxy_pass http://127.0.0.1:8080;
            include /etc/nginx/proxy_params;
            index index.php index.html index.htm;
   }
}

相关内容