HTTP 404 при тестировании приложения .Net Core через Apache Linux Server - PullRequest
0 голосов
/ 13 января 2019

У меня на локальном сервере IIS отлично работает приложение API .Net Core

Чтобы запустить его на сервере Linux Apache, я запускаю:

dotnet publish -c Release -r ubuntu.16.04-x64

Я копирую код из папки публикации и загружаю его в папку сервера / var / www / myapp

Я запускаю приложение через .dll и получаю вывод ниже:

Hosting environment: Production
Content root path: /var/www/myapp Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

Когда я тестирую веб-API через Postman, я получаю 404 или 503 (даже на localost: 5000 - без конечной точки)

CURL также не работает:

curl http://localhost:5000/myapp/api/auth/token
curl: (7) Failed to connect to localhost port 5000: Connection refused

Я учусь на ядре .net + .net, поэтому, пожалуйста, покажите мне, как это устранить.

Дайте мне знать, если вам нужна дополнительная информация.

EDIT:

Чтобы предоставить больше информации, я делаю большую часть через существующий сервер:

Я развертываю приложение по адресу: http://exampledomain.com

exampledomain - это допустимый домен, где Apache работает с

Я тестирую службу на http://exampledomain.com/myapp/api/auth/token через запрос HTTP POST используя конфигурацию ниже (/etc/apache2/sites-enabled/myapp.conf):

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port th                     at
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName exampledomain.com

        ServerAdmin webmaster@localhost
        #DocumentRoot /var/www/myapp

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ProxyPreserveHost On
        ProxyPass / http://localhost:5000/
        ProxyPassReverse / http://localhost:5000/

        ErrorLog ${APACHE_LOG_DIR}/dotnetcore-error.log
        CustomLog ${APACHE_LOG_DIR}/dotnetcore-access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


</VirtualHost>
...