我想我在这里是徒劳无功,所以我决定向各位大师请教。
我有两台机器,一台有反向代理 Nginx,另一台有运行多个虚拟主机的 Apache。
nginx 正确执行了 proxy_pass 并且我能够查看 index.html,但不能查看除此之外的任何其他文件。
我附加了 nginx 主机(nbte.com.br,(192.168.4.30))和 apache 虚拟主机(SIPREPWWPRESS03.simosa.inet)的 conf 文件
NGINX-083-nbte.conf
server {
listen 80;
server_name nbte.com.br www.nbte.com.br;
access_log /var/log/nginx/nbte.access.log;
error_log /var/log/nginx/nbte.error.log error;
error_page 404 403 /handle404.html;
#error_page 502 503 504 /handle503.html;
error_page 500 502 503 504 /handle500.html;
location = /handle404.html {
root html/errores-prxy;
}
location = /handle503.html {
root html/errores-prxy;
}
location = /handle500.html {
root html/errores-prxy;
}
location = / {
proxy_pass http://SIPREPWWPRESS03.simosa.inet/;
}
SIPREPWWPRESS03.simosa.inet 解析为 192.168.16.79
APACHE-021-nbte.conf
<VirtualHost 192.168.16.79:80>
ServerName nbte.com.br
ServerAlias nbte.com.br www.nbte.com.br
DocumentRoot "/apps/htmlsites/nbte"
ErrorLog "logs/error_nbte.log"
CustomLog "logs/nbte-access.log" combined
<LocationMatch "/*">
</LocationMatch>
<Directory "/apps/htmlsites/nbte">
Options +Indexes FollowSymLinks
#AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
# ModSecurity exceptions
<LocationMatch "/*">
SecRuleRemoveById 990011
SecRuleRemoveById 960017
SecRuleRemoveById 960015
SecRuleRemoveById 970013
</LocationMatch>
我几乎没有使用 NGINX 的经验,我对它非常陌生,特别是它的反向代理功能。尽管如此,我认为这是 NGINX 的问题,因为查看错误日志文件时,我发现每次请求静态文件时都会出现错误行:
2015/06/25 12:00:04 [error] 5075#0: *1393 open() "/etc/nginx/html/Informacoes-Financeiras-30-junho-2014-Norte-Brasil-Transmissora-Energia.pdf" failed (2: No such file or directory), client: 192.168.14.1, server: nbte.com.br, request: "GET /Informacoes-Financeiras-30-junho-2014-Norte-Brasil-Transmissora-Energia.pdf HTTP/1.1", host: "nbte.com.br", referrer: "http://nbte.com.br/"
2015/06/25 12:00:04 [error] 5075#0: *1393 open() "/etc/nginx/html/Informacoes-Financeiras-30-junho-2014-Norte-Brasil-Transmissora-Energia.pdf" failed (2: No such file or directory), client: 192.168.14.1, server: nbte.com.br, request: "GET /Informacoes-Financeiras-30-junho-2014-Norte-Brasil-Transmissora-Energia.pdf HTTP/1.1", host: "nbte.com.br", referrer: "http://nbte.com.br/"
文件Informacoes-Financeiras-30-junho-2014-Norte-Brasil-Transmissora-Energia.pdf位于 Apache 的文档根目录 /apps/htmlsites/nbte 内,其中包含 index.html
提前致谢。任何帮助都非常感谢。
答案1
这
location = / {
proxy_pass http://SIPREPWWPRESS03.simosa.inet/;
}
应该
location / {
proxy_pass http://SIPREPWWPRESS03.simosa.inet/;
}
按照http://wiki.nginx.org/HttpCoreModule#location
location = / {
# 仅匹配查询 /。
[ 配置 A ]
}location / {
# 匹配任何查询,因为所有查询都以 / 开头,但正
则 # 表达式和任何较长的常规块将
首先匹配。
[ 配置 B ]示例请求:
/ -> 配置 A
/index.html -> 配置 B