nginx-pache反向代理403错误

时间:2016-03-28 02:13:03

标签: apache nginx ubuntu-14.04 reverse-proxy

所以我决定试试反向代理,apache是​​'后端'服务。

似乎所有内容都已正确配置,我在线验证了几个指南的设置,但是当尝试访问“/ var / www /”时,nginx返回403错误

我的第一个倾向是检查权限,但似乎没有问题。即使将权限推送到每个目录\文件后,我也没有任何改变。

其次我想知道是否必须将“/ var / www /”的所有权设置为nginx的默认用户,但我不太确定。

下面我将分享nginx和apache的设置:

这是nginx / etc / nginx / sites-available / * -

的配置
server {
        listen   80; 

        root /var/www/; 
        index index.php index.html index.htm;

        server_name example.com; 

        location / {
        try_files $uri $uri/ /index.php;
        }

        location ~ \.php$ {

        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;

         }

         location ~ /\.ht {
                deny all;
        }
}

这是apache / etc / apache2 / sites-available / * -

的配置
<VirtualHost 127.0.0.1:8080>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

要完成,我正在运行Ubuntu 14.04,这里的一切都应该在localhost上运行,我只想玩反向代理以查看我是否喜欢它。

有什么线索我搞砸了吗?

- 我实际上想到了这一点,我没有允许目录访问Apache中的正确目录,因此它将使用403响应nginx。

0 个答案:

没有答案