Category Archives:

ASP.NET Core hosting in Apache using SSL and Cookie Authentication redirect

I've made an core application and I'm trying to host it in Apache with reverse proxy. The app uses cookie authentication:

app.UseCookieAuthentication(new CookieAuthenticationOptions()
  AuthenticationScheme = "CookieAuthentication",
  LoginPath = new PathString("/Account/Login/"),
  AccessDeniedPath = new PathString("/Account/Forbidden/"),
  AutomaticAuthenticate = true,
  AutomaticChallenge = true

In httpd.conf I would like to use one SSL only host with custom port which serves content from Kestrel.

Listen 34567

<VirtualHost *:34567>
  ProxyPreserveHost On
  ProxyPass /
  ProxyPassReverse /
  SSLEngine on
  SSLProtocol all -SSLv3
  SSLCertificateFile certs/server.crt
  SSLCertificateKeyFile certs/server.key

When I use url https://testserver1:34567 it redirects to http://testserver1:34567/Account/Login/?ReturnUrl=%2F which of course gives a Bad Request. If I correct the url by changing it to https, everything works fine afterwards.

How can I make it so that it always redirects to a https url?

Apache reverse Proxy in Plesk 12 (for ASP.Net Core)

At the moment I try to get running a ASP.Net Core Application on my server. This server runs Debian 8, Apache 2 and Plesk 12. The Application runs at port 5000 and I wanted to add a reverse proxy to a specific subdomain to make the application available outside.

I have created a subdomain and added additional configuration as follows:

RewriteEngine On
ProxyPreserveHost On
ProxyRequests Off
ProxyErrorOverride Off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/

When using this, I only get an error of the server when browsing stating

The server encountered an internal error or misconfiguration and was unable to complete your request.

I searched Stackoverflow, ASP.Net Core documentation and other forums, which actually state to use my config (or a subset of this). Installing nginx is not an option because of other projects running on this server.

Do you have an idea what I am missing?

Thanks for your help!

dotnet publish with an Apache server

I have a .NET Core application ready to deploy. I've already tested this application on my Linux (CentOS) server with the command:

dotnet run

and everything is running smothly. Now I want to publish this web application on my Apache server. So far I've runned the command

dotnet publish

which created a folder named netcoreapp1.0. I've moved that folder to the var/www/mywebsite folder and created the respective sites-enabled and sites-avaliable conf files. The problem is I cannot access application at all.

With this, I would like to know if there is anyone out there that had published a .NET Core application into an Apache server in order to give some tutorial on how they did it.