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>