在 Nginx 中打开 IP/文件夹

在 Nginx 中打开 IP/文件夹

我想从 IP/folder_name 打开一个没有域名的网站每次我尝试访问该网站时,我都会被重定向到同一服务器上的其他网站:这是我的默认配置:

server {
   listen 80 default;
   server_name localhost;
   root /usr/share/nginx/www/;
   location /justice.ma {
   root  /usr/share/nginx/www/justice.ma/;
}
 location / {
        index  index.html index.htm index.php;
    }
    location ~ \.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    }
}

其他网站配置(强制重定向到该网站):

        server {
            listen 80;
            server_name domain.com www.domain.com;
            root /usr/share/nginx/www/domain.com;
            return 301 https://domain.com;

}
# HTTPS server
#
server {
    listen 443;
    server_name  domain.com;

    root /usr/share/nginx/www/domain.com;
    index index.php;

    ssl on;
    ssl_certificate /usr/share/nginx/www/domain.com/domain.com.crt;
    ssl_client_certificate /etc/nginx/www/domain.com.ca;
    ssl_certificate_key /etc/ssl/private/domain.com.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;

location /phpmyadmin {
  alias /usr/share/phpmyadmin/;
  try_files $uri $uri/ /index.php;
}
location ~ ^/phpmyadmin(.+\.php)$ {
  alias /usr/share/phpmyadmin$1;
  fastcgi_pass php5-fpm-sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$1;
  include fastcgi_params;
}
    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    }
    location /uploads/ { 
    location ~ .*\.(php).*$ 
    { 
    deny all; 
    } 
        }
}

请帮忙!

答案1

  1. 清除浏览器缓存。
  2. 确保重定向来自 nginx,而不是您的 php 脚本。

相关内容