私はドキュメントを読み、例をスキャンしましたが、これが機能しない理由を一生理解できません。私は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/location1/index.html
移動するとドキュメントが返されます。等号を削除して、一致に使用できるさまざまな演算子を使用しようとしましたが、何も機能しないようです。おそらく、私が誤解しているのはかなり基本的なものであり、このようなものには慣れていません。私も正規表現が苦手です。誰か啓発したいですか?domain.com/othersite
index.html
/home/TMlabs/server_files/location2
編集:何が起こっているのかは、実際には私のディレクティブを完全に無視していて、単に/usr/share/nginx/www
ドキュメント ルートとして使用していると思います。この設定はどこにもありません。私は何が欠けていますか?