在位置使用具有多个根的Nginx

问题描述

我正在尝试为应用程序中的位置设置多个根。

我的mainapp是从根目录"../gestan-cloud/dist"

提供的

但是,我有一个查看器文件夹,其中包含"../gestan-cloud/node_server_app/viewer"和其他“ index.html”。

我需要将该文件放入应用页面中的iframe中。

我的mais应用程序运行良好,但无法使iframe正常工作。

"index.html"中的"../gestan-cloud/node_server_app/viewer"从未显示在iframe中。

我的页面无法加载iframe。 "/gestdicom/default.html"是伪造的url,仅用于Nginx重定向"../gestan-cloud/node_server_app/viewer/index.html"

<div>
    <iframe
      src="/gestdicom/default.html"
      width="100%"
      height="100%"
      frameborder="0"
    ></iframe>
  </div>
 

我的应用文件夹:

\mainApp
|   \gestan-cloud
|      \dist
|          index.html
|          \css
|      \node_server_app
|          \viewer
|             index.html
|
|   \Nginx-1.18.0
|       \conf         
|       \docs
|       ....

    

//这是我的Nginx文件配置文件

worker_processes  2;
error_log  logs/error.log;
error_log  logs/error.log  notice;
events {
    worker_connections  1024;
}

http {
    rewrite_log on;
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    gzip  on;

    # Enable SSL
    ssl_certificate  ../ssl/cert.pem;
    ssl_certificate_key ../ssl/key.pem;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;

    server {
       listen          80;
       listen         [::]:80;
       return 301 https://$host$request_uri;
    }
    
    server {
        listen 443 ssl;
        server_name gestan1.myapp.local;
        
        #main app index.html
        location / {
         root     ../gestan-cloud/dist;
         index    index.html index.htm;
         try_files $uri $uri/ /index.html;
        }
        location ~ ^/(api|uploads|public)/ {
            access_log off;
            proxy_pass http://localhost:3001$request_uri;
        }
        
        #socket io
        location ~* \.io {
          access_log off;
          include proxy_io_params.conf;
          proxy_pass http://localhost:3001;
        }


        #redirect para o server ohif
        location /gestdicom/ {
          root     ../gestan-cloud/node_server_app/viewer;
          index  index.html;
          rewrite ^/gestdicom(.*)$ /$1; 
          try_files $uri $uri/ =404;
        }
        
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)