如何访问 url 的静态文件

时间:2021-07-16 04:47:55

标签: nginx http-status-code-404

我想从托管在 url 上的应用程序访问 /usr/share/nginx/html 中存在的静态文件,例如 http://login.redirect.com

例如,如果我访问 url http://main-app/login.com 上的应用程序,它应该从文件夹 /usr/share/nginx/html 中的 http://login.redirect.com 提供文件

我已经在主应用程序中编写了一个 nginx 文件

server {
         listen 8080;
         server_name main-app.com; 

         port_in_redirect off;
         autoindex on;

          location /login {
            add_header X-debug-message "A static file was served in container" always;   
            alias   /usr/share/nginx/html;
            index  index.html index.htm;
         }


      }

使用它,主应用程序仍然会从它自己的文件夹中查找静态文件..

0 个答案:

没有答案