首页 > 解决方案 > 我的资源是在 https 而不是 http 下加载的

问题描述

我在 Raspberry Pi 上使用 Asp.Net Core 并使用 NGINX 作为我的服务器。

在我看来:我有这些(等):

<script src="~/js/Messanger.js" asp-append-version="true"></script>

但它被服务(并且未能服务)为

https://192.168.0.12/js/Messanger.js

我尝试使用完整路径(因为我知道 IP)

<script src="http://192.168.0.12/js/Messanger.js" asp-append-version="true"></script>

我的打开页面被用作 http。

我在我的项目设置中禁用了 SSL。

我已经注释掉了:app.UseHttpsRedirection(); 在 startup.cs 中并已更改:

 "applicationUrl": "https://localhost:5001;http://localhost:5000"

"applicationUrl": " http://localhost:5001;http://localhost:5000 "

在 LaunchSettings.json 中(虽然我知道这没有在发布中部署)。

在我的 Rpi 上 nginx 的默认配置中,我有:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

location /MyServer/ {
        proxy_pass http://localhost:5000/;
        proxy_http_version 1.1;
        proxy_set_header Connection keep-alive;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host   $http_host;
        proxy_set_header X-Forwarded-Proto  http;
        proxy_set_header X-Forwarded-Path   /MyPath;
}

标签: redirectasp.net-corehttps

解决方案


推荐阅读