Welcome! Log In Create A New Profile

Advanced

index file not showing - index of /

Posted by torchsonghq 
index file not showing - index of /
October 25, 2011 12:50AM
Hi.
I've followed the guide here: http://olex.openlogic.com/wazi/2011/add-a-nginx-reverse-proxy-to-your-lamp-setup/

So my nginx virtualhost file looks like this:

server {
listen 80;
server_name mydomain.ltd www.mydomain.ltd;
access_log off;
error_log off;
location / { proxy_pass http://127.0.0.1:8080; }
location ~* ^.+\.(htm|html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|bz2|pdf|odt|txt|tar|bmp|rtf|js|swf|avi|mp4|mp3|ogg|flv)$ {
expires 30d; #adjust to your static content's update frequency
root /home/mydomain.ltd/public_html;
index index.html index.php;
}
}

So whenever I head to mydomain.ltd I get "Index of /" page. If i go mydomain.ltd/index.html the file shows up correctly.

any ideas?
Re: index file not showing - index of /
October 25, 2011 07:00PM
Hi,

Maybe try to move index command into your location / block:

location / {
proxy_pass http://127.0.0.1:8080;
index index.html index.php;
}

I'd also move root command into your main server configuration block.

server {
...
root /home/mydomain.ltd/public_html;
...
}



Edited 1 time(s). Last edit at 10/25/2011 07:01PM by locojohn.
Re: index file not showing - index of /
October 25, 2011 11:34PM
Thank you for reply.
Unfortunately, that didn't help.

Also I separated the root command as I'm making multiple hosts.
Re: index file not showing - index of /
October 26, 2011 12:15AM
What I've noticed is that it is following the "Main" server setting of httpd/conf/httpd.conf - how can I disable the main server's setting then make the server follow nginx's root config files?



Edited 1 time(s). Last edit at 10/26/2011 12:16AM by torchsonghq.
Re: index file not showing - index of /
October 26, 2011 06:07AM
Hi

Not sure I understood what you meant by " it is following the "Main" server setting of httpd/conf/httpd.conf ". Are you running Apache as the backend server?

Please post your nginx.conf.

Andrejs
Re: index file not showing - index of /
October 26, 2011 08:50AM
Yes, I'm using nginx as reverse proxy.
Here's my nginx.conf

user apache; #change to the same user apache runs as
worker_processes 2; #change to the number of your CPUs/Cores
worker_rlimit_nofile 8192;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
use epoll;
accept_mutex off;
}

http {
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;

# reverse proxy options
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;

# gzip compression options
gzip on;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_min_length 0;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types text/plain text/css text/xml text/javascript application/xml application/xml+rss application/javascript application/json;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;

# include virtual hosts configuration
include /etc/nginx/virtual.d/*.conf;
}
Re: index file not showing - index of /
October 27, 2011 08:54AM
I think I got it.

Some of the default main server settings from httpd.conf were commented out:

#ServerName www.example.com:80

I changed this to

ServerName mydomain.ltd:8080
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 199
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready