2

请耐心等待,因为这是一个很长的问题,但我被严重卡住了。

客观的

我想在 Nginx 上基于 linux 的服务器上运行我的 ssl 配置构建,我想在我的域https://dev.server.nl上使用资源/ggmd/webconsolehttps://dev.server.nl/访问它ggmd/网络控制台

我遵循的步骤

我已经在webconsole文件夹中的 linux 服务器机器上部署了我的 angular 4 版本。路径类似于 /opt/web/dev/ggmd/webconsole ,我所有的构建文件都在其中。

网络控制台

我通过在默认文件中进行配置在 nginx 服务器上运行构建。

server {
    listen 4200 default_server;
    root /opt/web/dev/ggmd/webconsole;
    index index.html index.htm;
    server_name localhost;
    location / {
        try_files $uri $uri/ /index.html;
    }
}

我的基本href设置为<base href="/ggmd/webconsole/">

<!doctype html>
<html lang="en">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
      <meta charset="utf-8"> 
    <title>GGMD Console</title>
    <base href="/ggmd/webconsole/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
<script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="scripts.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
</html>

我在域上访问 URl 的映射配置如下:

location /ggmd/webconsole {
        proxy_pass http://13.26.100.155:4200;
        proxy_redirect http://13.26.100.155:4200 https://dev.w-integrate.nl/ggmd/webconsole;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

问题陈述

  1. 我无法通过 https 上的 IP 访问它,但是当我尝试通过HTTP访问时 http://13.26.100.155:4200/ggmd/webconsole/

我重定向到我在我的角度路由器代码中定义和制作的角度应用程序的 404 页面。

  1. 当我尝试使用重定向代理访问时,我无法在 http 上访问它,但是当我在 https://dev.w-integrate.nl/ggmd/web/console 上尝试 https

我在浏览器控制台中收到以下错误。

拒绝从 inline.bundle.js' 执行脚本,因为它的 MIME 类型 ('text/html') 不可执行,并且启用了严格的 MIME 类型检查。

在此处输入图像描述

当我从我的基本 href 和重定向配置中删除“ /ggmd/webconsole/ ”时,如下所示

<base href="/">和我的重定向配置到以下

location / {
            proxy_pass http://13.26.100.155:4200;
            proxy_redirect http://13.26.100.155:4200 https://dev.w-integrate.nl/;

            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }

然后我就可以访问我的项目了

https://dev.server.nl/

http://13.26.100.155:4200(不在 HTTPS 上)

但我想在 https 和 /ggmd/webconsole 资源https://dev.server.nl/ggmd/webconsole上运行它

我怎样才能做到这一点?如有打字错误请见谅。

编辑:解决方案

端口 443 已与服务器标签服务器下的一些其他证书一起使用 { //configurations }

我在服务器标签下方的服务器标签中添加了我的配置,其中端口为 443,基本 href 为“/”

我的配置如下:

server {
    listen 4200 ssl;

        ssl_certificate /opt/web/dev/ggmd/webconsole/devcom.crt;
        ssl_certificate_key /opt/web/dev/ggmd/webconsole/devcom.key;

    root /opt/web/dev/ggmd/webconsole;
    index index.html index.htm;
    server_name dev.w-integrate.nl;

        location /ggmd/webconsole(.*)$ {
        proxy_pass https://83.96.205.55:4200;
        proxy_redirect https://83.96.205.55:4200 https://dev.w-integrate.nl/ggmd/webconsole;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }
    location / {
        try_files $uri $uri/ /index.html;
    }
}

现在我可以访问 https 但正在发生以下情况:

通过 IP https://13.26.100.155:4200/ggmd/webconsole

我通过角度路由被路由到我的角度应用程序的 404 页面,并且

通过反向代理https://dev.server.nl/ggmd/webconsole/

我被路由到 nginx 的 404 页面

现在有什么问题?

4

1 回答 1

1

你能看看这个文件是否有效

server {
        listen 443 ssl;

        server_name <YOUR_DOMAIN_NAME eg www.example.com>;

        ssl_certificate /path/to/rapid_ssl.crt;
        ssl_certificate_key /path/tp/cert/rapid_ssl.key;

        location /ggmd/webconsole(.*)$ {
        proxy_pass http://13.26.100.155:4200;
        proxy_redirect http://13.26.100.155:4200 https://dev.w-integrate.nl/ggmd/webconsole;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

        location / {
                try_files $uri $uri/ /index.html;
        }
}
于 2017-11-14T06:44:29.213 回答