即使我将root
指令改为指向/var/www/html
,nginx 仍尝试从/var/www
我的根目录中加载文件。
我已经重新启动了 nginx,并在更改 default.conf 后收到“OK”。
我做错什么了吗?值得注意的是,这个 nginx 服务器正在 docker 容器内运行。
==================================
/etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile off;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log ;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/默认.conf
server {
listen 80 default_server;
server_name _;
index index.cfm index.html index.htm;
root /var/www/html;
server_name_in_redirect off;
set $path_info $request_uri;
try_files $uri /index.cfm?$args;
location ~* \.(cfm|cfc|cfr)$ {
proxy_pass http://127.0.0.1:8888;
proxy_redirect off;
proxy_set_header Host $host;
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_set_header XAJP-PATH-INFO $path_info;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
}
}
答案1
您已将 nginx 配置为将此root
路径用于您的网站。这适用于 nginx 提供的静态资源。
但是,您的应用程序服务器不使用 nginxroot
选项,因为它独立于 nginx。
您需要修复您的应用程序服务器配置。