我尝试了很多东西,STFW,RTFM,但是我仍然有这个问题。 事情是:
我有一个Nnginx安装在一台AWS机器上(其他的机器安装了它,而不是我),我必须提供几个虚拟主机(* .conf文件)从其他服务器(生产机器)
我的主要问题是这个.conf文件中的error handling程序path是亲戚,例如:
html/errores-prxy/handle404.html
如在
location = /handle404.html { root html/errores-prxy; }
问题是为这个处理程序调用的文档根path是/ usr / share / nginx,正如我在错误日志中看到的那样:
2015/04/30 10:33:24 [error] 19542#0: *68 open() "/usr/share/nginx/html/errores-prxy/handle404.html" failed (2: No such file or directory), client: 77.240.116.140, server: www.abengoa.com, request: "GET / HTTP/1.1", upstream: "http://172.26.3.9:80/web/", host: "www.abengoa.es"
在这台AWS机器上,Nginx安装在/ etc / nginx中。 这些处理程序文件位于/etc/nginx/html/errores-prxy/handle404.html
所以我的问题是,如何让Nginx在/ etc / nginx而不是在/ usr / share / nginx /?
我可以创build一个脚本来将相对path更改为所有* .conf文件中的绝对path,但是我正在寻求一个更优雅的解决scheme,就像更改Nginx文档根目录一样。
提前谢谢了。
下面是我的nginx.conf(位于/etc/nginx/nginx.conf中,以防万一)
用户nginx nginx; worker_processes 2; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; 事件{ worker_connections 4096; } http { 包括/etc/nginx/conf/mime.types; default_type application / octet-stream; 发送文件; gzip on; gzip_comp_level 9; gzip_min_length 0; gzip_proxied expired no-cache no-store private auth; gzip_types文本/纯文本/ css应用程序/ x-javascript应用程序/ xml应用程序/ javascript; set_real_ip_from 192.168.151.3; real_ip_header X-Forwarded-For; proxy_set_header主机$主机; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_intercept_errors on; log_format main'$ remote_addr - $ remote_user [$ time_local]' '“$ request”$ status $ body_bytes_sent“$ http_referer”' '“$ http_user_agent”'; access_log /var/log/nginx/access.log main; client_max_body_size 50m; client_body_buffer_size 4k; client_header_buffer_size 2k; keepalive_timeout 5 5; client_body_timeout 10; client_header_timeout 10; send_timeout 10; proxy_connect_timeout 5; proxy_send_timeout 20; proxy_read_timeout 120; proxy_buffer_size 8k; proxy_buffers 8 32k; proxy_busy_buffers_size 32k; proxy_temp_file_write_size 32k; server_names_hash_bucket_size 128; server_names_hash_max_size 1280; server_name_in_redirect off; proxy_cache_path / etc / nginx / cache levels = 1:2 keys_zone = prxy-cache:100m max_size = 256m; proxy_cache_key“$ scheme $ host $ request_uri”; 包括/etc/nginx/conf/*.conf; 包括/etc/nginx/conf/sites-enables/*.conf; }