在Nginx上托管前端和后端

时间:2018-09-06 18:29:17

标签: nginx nginx-location nginx-reverse-proxy

我试图在nginx上托管我的AngularJs应用和dotnet核心api,但是我无法访问我的api,以下是我的/etc/nginx/conf.d中的default.conf:

server {

listen 80 default_server;
listen [::]:80 default_server;

root /var/www/dashboard;

index index.html;

server_name example.server.com;

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

location /api {
 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;
}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

}

0 个答案:

没有答案