2

I have the following problem:

I want to access a mono application via ssl. I want it to be not accessible without ssl.

I am using apache2.4 and mod-mono-server4.exe 3.0.0.0

At the moment I have a working configuration like this:

<VirtualHost *:80>

    DocumentRoot /srv/www/htdocs/my-mono-app

    #SSLEngine on
    #SSLCertificateFile   /path/to/key.pem
    #SSLCertificateKeyFile /path/to/key.pem

    MonoAutoApplication disabled

    MonoServerPath my-mono-app "/usr/bin/mod-mono-server4"

    MonoApplications my-mono-app "/my-mono-app:/srv/www/htdocs/my-mono-app"

    <Directory /srv/www/htdocs/my-mono-app>
        Require all granted
        MonoSetServerAlias my-mono-app
        SetHandler mono
    </Directory>
</VirtualHost>

But as soon as I turn the SSLEngine on and change the port to 443 it does not work anymore. It just says: Object not found! if i navigate to the address.

It does not record any errors in the logs.

Can you help me with this please?

PS: Here is the complete not working configuration:

<VirtualHost *:443>

    DocumentRoot /srv/www/htdocs/my-mono-app

    SSLEngine on
    SSLCertificateFile   /path/to/key.pem
    SSLCertificateKeyFile /path/to/key.pem

    MonoAutoApplication disabled

    MonoServerPath my-mono-app "/usr/bin/mod-mono-server4"

    MonoApplications my-mono-app "/my-mono-app:/srv/www/htdocs/my-mono-app"

    <Directory /srv/www/htdocs/my-mono-app>
        Require all granted
        MonoSetServerAlias my-mono-app
        SetHandler mono
    </Directory>
</VirtualHost>
Simon Zyx
  • 6,503
  • 1
  • 25
  • 37

1 Answers1

0

I used mono 5.x once. From that experience what I can recall, mod_mono.conf needed modification for directory path. I reached that solution from Apache access and error logs. I tried many ways before that searching the whole earth - symlinking, purge installation and building from source etc. You may try my way keeping a backup of mod_mono.conf.

<IfModule !mono_module>
    LoadModule mono_module "libexec/apache2/mod_mono.so"
</IfModule>

<IfModule mono_module>
    AddType application/x-asp-net .config .cs .csproj .dll .resources .resx .sln .vb .vbproj
    AddType application/x-asp-net .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo

    MonoAutoApplication enabled
    MonoDebug true
    MonoServerPath "/usr/bin/mod-mono-server4"
    MonoSetEnv LANG=fr_FR.UTF-8
    MonoUnixSocket "/tmp/.mod_mono"

    <IfModule dir_module>
        DirectoryIndex Default.aspx
    </IfModule>

    <DirectoryMatch "/(bin|App_Code|App_Data|App_GlobalResources|App_LocalResources)/">
        Order deny,allow
        Deny from all
    </DirectoryMatch>

    <Location "/my-mono-app">
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1 ::1
        SetHandler mono-ctrl
    </Location>
</IfModule>

It was too bigger to write as comment, it is possibly not 100% warranted answer, depends on your try. That thing in your config is correct :

Require all granted
MonoSetServerAlias my-mono-app
SetHandler mono

Without that stanza odd errors appear.

Abhishek Ghosh
  • 1,161
  • 9
  • 19
  • If i put the directory in the mod_mono.conf file, i have the problem that the application is still accessible without ssl - and i would like to have it only accessible via ssl. The wording in my question was a little bad, i updated it. – Simon Zyx Aug 04 '17 at 10:32
  • For old version of Mono, you can simply add a reverse proxy server in front and redirect all non-HTTPS traffic to HTTPS. – Abhishek Ghosh Aug 04 '17 at 20:29