【问题标题】:Angular5 with Asp.Net Core 2.1 application deployment problem on nginxAngular5 与 Asp.Net Core 2.1 应用程序在 nginx 上的部署问题
【发布时间】:2018-09-15 16:54:53
【问题描述】:

我正在尝试部署 Angular 5 应用程序 Digital Ocean Ubuntu 16.4 Nginx。但是 Angular 应用程序无法从那里正常工作。

我可以做到以下几点:

http:://ipaddress/api/values http://domainname/api/values

但是 Angular 的网站不工作:

http://domainname http://ipaddress

我尝试了几种组合来访问该应用程序,但它对我不起作用。

你可以看到下面的nginx默认文件:

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        location / {
                proxy_pass http://localhost:5000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection keep-alive;
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }
        # 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;
        root /home/xxxx/www;


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

#       server_name _;

#       location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
#               try_files $uri $uri/ =404;
        #       proxy_pass http://localhost:4200;
        #}
}

使用这个默认文件,我已经完成了多个位置,但它再次不起作用。

您能否告诉我如何部署与 dotnetcore 2.1 api 一起运行的 Angular 应用程序。

【问题讨论】:

    标签: angular nginx asp.net-core ubuntu-16.04 digital-ocean


    【解决方案1】:

    不知何故在 dotnet app.UseStaticFiles();被评论了。我删除了 cmets,是的,它开始工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-01
      • 2021-05-08
      • 1970-01-01
      • 2019-05-23
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多