Redirect 我的资源是在https而不是http下加载的

Redirect 我的资源是在https而不是http下加载的,redirect,asp.net-core,https,Redirect,Asp.net Core,Https,我在Raspberry Pi上使用Asp.Net内核,并使用NGINX作为我的服务器 在我看来:我有这些(等): 我已尝试使用完整路径(因为我知道IP) 到 “应用程序URL”:” 在LaunchSettings.json中(尽管我知道这个版本中没有部署) 在我的Rpi上nginx的默认配置中,我有: server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration

我在Raspberry Pi上使用Asp.Net内核,并使用NGINX作为我的服务器

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

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

“应用程序URL”:”

在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;
}

您以前可能已经在此应用程序或在localhost上运行的其他站点上应用了HST。HSTS防止SSL降级,因此一旦HSTS在域上注册(即使是本地主机),只允许使用HTTPS,如果尝试HTTP请求,浏览器将自动重定向到HTTPS。每个浏览器都有不同的方法来修改站点的HSTS预设,因此您需要搜索特定浏览器以获取说明。@ChrisPratt有趣。我只使用了几个浏览器,都有相同的问题,升级到https。所以,看来我需要为我的树莓Pi获得ssl证书?那么,每个Pi都需要一个证书?我读对了吗?谢谢。首先检查每个浏览器中的HSTS设置。浏览器中通常会有一个应用了HST的站点列表,您只需从该列表中删除localhost即可。然而,最好还是直接使用HTTPS,而不必担心它。为此,每个域只需要一个证书,所以本地主机一个证书就足够了。显然,您需要进行自签名,因为localhost不是一个真正的域,您可以向实际的CA注册。然后,您只需将它添加到任何客户端计算机的受信任存储中即可。@ChrisPratt感谢您提供的信息。虽然我可以为我的浏览器计算并更改HST,但对于从他们的浏览器中查看我的网站的任何其他人,我将无法做到这一点。所以,我想https是一种方式。感谢您以前可能在此应用程序或在localhost上运行的其他网站上应用了HST。HSTS防止SSL降级,因此一旦HSTS在域上注册(即使是本地主机),只允许使用HTTPS,如果尝试HTTP请求,浏览器将自动重定向到HTTPS。每个浏览器都有不同的方法来修改站点的HSTS预设,因此您需要搜索特定浏览器以获取说明。@ChrisPratt有趣。我只使用了几个浏览器,都有相同的问题,升级到https。所以,看来我需要为我的树莓Pi获得ssl证书?那么,每个Pi都需要一个证书?我读对了吗?谢谢。首先检查每个浏览器中的HSTS设置。浏览器中通常会有一个应用了HST的站点列表,您只需从该列表中删除localhost即可。然而,最好还是直接使用HTTPS,而不必担心它。为此,每个域只需要一个证书,所以本地主机一个证书就足够了。显然,您需要进行自签名,因为localhost不是一个真正的域,您可以向实际的CA注册。然后,您只需将它添加到任何客户端计算机的受信任存储中即可。@ChrisPratt感谢您提供的信息。虽然我可以为我的浏览器计算并更改HST,但对于从他们的浏览器中查看我的网站的任何其他人,我将无法做到这一点。所以,我想https是一种方式。感谢
https://192.168.0.12/js/Messanger.js
<script src="http://192.168.0.12/js/Messanger.js" asp-append-version="true"></script>
 "applicationUrl": "https://localhost:5001;http://localhost:5000"
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;
}