문서를 읽었으며 예제를 스캔했는데 왜 작동하지 않는지 알 수 없습니다. 나는 완전히 nginx에 익숙하다. 그래서 이것이 어리석은 간단한 대답이라면, 나에게 쉽게 가라.Nginx가 위치 지시어를 무시합니까?
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
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_disable "msie6";
# 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;
##
# Virtual Host Configs
##
#include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
server {
listen 80;
server_name localhost domain.com;
root /home/TMlabs/server_files;
index index.html index.htm;
location = /othersite {
root /home/TMlabs/server_files/location2;
index index.html index.htm;
}
location/{
root /home/TMlabs/server_files/location1;
index index.html index.htm;
}
}
더 많이 포함해야한다면 알려 주시기 바랍니다. 전체 nginx.conf를 덤프합니다. 그래도 꽤 기본입니다.
내가 달성하고자하는 것은 domain.com을/(작동 중) 위치에 지정된 루트에 매핑하고 domain.com/othersite를 해당 지시문에 지정된 루트에 매핑하는 것입니다. 어떤 이유로 든/home/TMlabs/server_files/location2 폴더의 index.html 파일보다는 domain.com/othersite를 탐색 할 때 /home/TMlabs/server_files/location1/index.html 문서를 반환합니다. 나는 equals를 제거하고 다른 연산자를 사용하여 일치를 시도했지만 아무 것도 작동하지 않는 것 같습니다. 아마도 내가 오해하고있는이 기본 요소에 익숙하지 않을 수도 있습니다. 나는 또한 regexp에서 빨아. 누구든지 계몽에 관심이 있습니까?
편집 : 내 생각에 실제로는 내 지시문을 완전히 무시하고 단순히/usr/share/nginx/www를 문서 루트로 사용하고 있습니다. 나는이 설정이 어디에도 보이지 않는다. 나는 무엇을 놓치고 있습니까?
내부의
default_type
지시어를 사용할 수 있습니다. 더 자세하게 게시하십시오. – Dayo나머지를 추가했습니다. 저는 템플릿에서 일하고 있습니다. 나머지는 템플릿입니다. 위에서 게시 한 전체 구성의 –
에 http 블록의 닫는 괄호가 없습니다. 또한 색인 지시문이 상속되므로 각 위치 블록에서 반복하지 않아도됩니다. 그리고/othersite는 특정/othersite url 만 일치한다는 것을 의미합니다. 아마도 당신이 원하는 것이 아닌 어떤 서브 페이지가 아닙니다. – cobaco