我有3个域名,并试图使用Nginx在一台服务器上托管所有3个网站(一个数字海洋液滴)。
mysite1.name
mysite2.name
mysite3.name
只有1个有效。另外两个结果是403个错误(以同样的方式)。
在我的nginx错误日志中,我看到:[error] 13108#0: *1目录索引“/usr/share/nginx/mysite2.name/live/”被禁止。
我的站点启用配置是:
server {
server_name www.mysite2.name;
return 301 $scheme://mysite2.name$request_uri;
}
server {
server_name mysite2.name;
root /usr/share/nginx/mysite2.name/live/;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.html index.php;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
这三个站点都有几乎相同的配置文件。
每个站点的文件都在/usr/share/nginx/mysite1.name/someFolder这样的文件夹中,然后/usr/share/nginx/mysite1.name/live是指向该文件夹的符号链接。(mysite2和mysite3也是如此。)
我已经查看了Nginx 403禁止所有文件,但这没有帮助。
有什么问题吗?
6833#0: *1 directory index of "/path/to/your/app" is forbidden, client: 127.0.0.1, server: lol.com, request: "GET / HTTP/1.1", host: "localhost"
我正在运行Ubuntu 15.10,由于一个简单的原因,我遇到了403 Forbidden错误。
在nginx.conf(nginx的配置文件)中,用户是'www-data'。
一旦我将用户名更改为[我的用户名],假设必要的权限被赋予我的用户名,它就能正常工作。
我遵循的步骤:
chmod 755 /path/to/your/app
我的配置文件是这样的:
**user [my username]**;#I made the change here.
worker_processes auto;
pid /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;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# 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/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 My_Server;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}