Questions & Answers

Nginx 403 forbidden caused by incorrect index page

My correct index page is index.php but Nginx directed me to index.html everytime when I access it, however page index.html didn't exist in the root diractory thus resulted in 403 forbidden. I tried to manually access some pages, but it downloaded page files for me instead of displaying them (for example when I enter (my domain)/index.php the page downloads as a file (Do you want to download index.php?) instead of displays as a webpage).

I tried to change the default index page by editing nginx.conf, however nothing happened.

Here is my nginx.conf file

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/;
load_module modules/;
load_module modules/;

events {
    worker_connections  1024;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /data/thebveforum;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {

        error_page 404 /404.html;
        location = /40x.html {

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {

2023-01-18 00:05:20
What you have shown is main nginx config, and it includes other files, using "include" directive. The root of the problem probably is in one of these included files, could you show them too?
Answers(0) :