【发布时间】:2014-04-08 09:05:53
【问题描述】:
我正在使用 grails 2.2.2 在本地计算机上进行项目 Mac OSX Lion 10.7.5 我已经安装了 NGINX 和 brew 并修改了 nginx.conf 如下:
worker_processes 1;
error_log logs/error.log info;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 8081;
server_name localhost;
root /;
access_log /Users/lorenzo/grails/projects/logs/myproject_access.log;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8081;
}
#images folders
location /posters {
root /Users/lorenzo/grails/projects/posters/;
}
#images folders
location /avatars {
root /Users/lorenzo/grails/projects/avatars/;
}
#images folders
location /waveforms {
root /Users/lorenzo/grails/projects/waveforms/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
当我访问http://localhost:8081 时,我的网站正在运行,但我想确保images 由nginx 提供服务,而不是由tomcat 提供服务,所以我查看myproject_access.log,但没有任何反应。
ngnix仅在tomcat不运行时写入日志。
有没有办法“监控”nginx 提供的静态文件?
谢谢
编辑
Executing curl -I http://localhost:8081
tomcat 运行时输出为:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1 //TOMCAT
...
当 tomcat 未运行时,输出为:
HTTP/1.1 500 Internal Server Error
Server: nginx/1.4.1 //NGINX
Date: Tue, 08 Apr 2014 09:30:00 GMT
Content-Type: text/html
Content-Length: 192
Connection: keep-alive
【问题讨论】: