ASP.NET Core 3.1 Web Api - hostowanie na Linuksie, nie działa swagger

0

Cześć,

ćwiczę sobie budowanie WebApi. Stworzyłem proste api testowe, zainstalowałem środowisko wykonawcze na serwerze z debianem i apache.
Samo API działa bezbłędnie. Jedyny problem jest taki, że nie wyświetla mi się dokumentacja generowana automatycznie przez swagger.
Kiedy API odpalałem developersko na IIS Express i localhost wszystko ładnie działało i dokumentacja była dostępna pod adresem: localhost:port/swagger/index.html.
api testowo jest pod api.itmey.pl, więc swagger zakładałem, że będzie: api.itmey.pl/swagger/index.html, niestety strona jest pusta.

Kompletnie nie wiem gdzie szukać problemu. Pomożecie?
Poniżej moje configi:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseCertificateForwarding();

            app.UseAuthentication();
           

            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Testowe API (.NET Core 3,1 Web API) V1");
            });
        }
[Unit]
Description=Example .NET Web API App running on Apache

[Service]
WorkingDirectory=/var/www/testApi/
ExecStart=/usr/bin/dotnet /var/www/testApi/NetCore3WebAPI.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production

[Install]
WantedBy=multi-user.target
<VirtualHost *:*>
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>

<VirtualHost api.itmey.pl:80>
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:5000/
    ProxyPassReverse / http://127.0.0.1:5000/
    ServerName api.itmey.pl
    ErrorLog ${APACHE_LOG_DIR}helloapp-error.log
    CustomLog ${APACHE_LOG_DIR}helloapp-access.log common
</VirtualHost>

1

Dostajesz 500 w zwrotce:

screenshot-20200403211035.png

Najlepiej sprawdź logi ;)

0

O najprostszym nie pomyślałem...

W logach apache nic nie ma, gdzie jeszcze mogę szukać informacji?

0

w jakimś journalu czy systemctlu nie będzie? tam powinny być logi z std output

https://unix.stackexchange.com/questions/225401/how-to-see-full-log-from-systemctl-status-service

journalctl -u service-name

3

Spróbuj włączyć komunikaty o błędach:
https://stackoverflow.com/a/39238793/10671389

0

Niestety, tylko tyle:

 kestrel-helloapp.service - Example .NET Web API App running on Apache
   Loaded: loaded (/etc/systemd/system/kestrel-helloapp.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-04-03 20:21:06 CEST; 2h 6min ago
 Main PID: 21114 (dotnet)
    Tasks: 14 (limit: 4915)
   Memory: 30.9M
      CPU: 10.151s
   CGroup: /system.slice/kestrel-helloapp.service
           └─21114 /usr/bin/dotnet /var/www/testApi/NetCore3WebAPI.dll

Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverCo
ntext context)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext
 context)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.GetService(IServiceProvider sp, Type type, Type middleware)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at lambda_method(Closure , Object , HttpContext , IServiceProvider )
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Apr 03 22:27:23 vps524884 dotnet-example[21114]:    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

0

nie da się więcej linijek pokazać? jakiś parametr do tego powinien być. Albo po prostu wyłącz ten service i odpal to ręcznie dotnet run / dotnet NetCore3WebAPI.dll czy tam ./NetCore3WebAPI

Albo jakbyś miał odpalone te czytanie logów na ssh i wszedł na swaggera z przeglądarki

1 użytkowników online, w tym zalogowanych: 0, gości: 1