sabre-io / Baikal

Baïkal is a Calendar+Contacts server
https://sabre.io/baikal/
GNU General Public License v3.0
2.5k stars 288 forks source link

Please support nginx with Baikal2 #297

Closed HLFH closed 8 years ago

HLFH commented 9 years ago

There is no nginx conf to use with Baikal2. Please add one.

shoeper commented 9 years ago

this works in my setup (edit: with baikal 0.2.x):

server {
        listen 80;
        server_name dav.example.me;

        return         301 https://$server_name$request_uri;
}

server {
    listen       443 ssl;
    server_name  dav.example.com;

    access_log  /var/log/nginx/com.example.dav.access.log;
    error_log   /var/log/nginx/com.example.dav.error.log;

    ssl_certificate     /path/to/crt/com.example.bundle.pem;
    ssl_certificate_key /path/to/crt/com.example.bundle.key;

    root  /var/www/com.example.dav/html/;
    index index.php;

        rewrite ^/.well-known/caldav /cal.php redirect;
        rewrite ^/.well-known/carddav /card.php redirect;

    charset utf-8;

    location ~ /(\.ht|Core|Specific) {
        deny all;
        return 404;
    }

    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";

    location ~ ^(.+\.php)(.*)$ {
        try_files $fastcgi_script_name =404;
        fastcgi_split_path_info  ^(.+\.php)(.*)$;
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        include        fastcgi_params;
    }
}
untitaker commented 9 years ago

I just use the same thing as ownCloud. It works just fine, and I think it would be unnecessary duplication to also include it in Baikal's docs.

fgordon commented 9 years ago

And please add support to deploy Baikal2 in a subdirectory with nginx. It's very importent because ssl-cert are expensive and micro-computer (like raspberry pi) plus FQDN are very cheap ;-)

artjom commented 9 years ago

In the meantime, did someone managed to get it up and running with nginx?

ghost commented 8 years ago

Baikal2 is based on Symfony2 (hopefully later Symfony3). That because you can use these configurations: http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html

This should work fine! If any issue occurs please report it as issue.

waitfor1t commented 8 years ago

I have Baikal2 running with Nginx no problem. The above comment from @JHGitty helped. Of course, SSH is mandatory, so I recommend the following modification:

# Baikal2 NGINX server configuration. Place in /etc/nginx/sites-available and ln -s to sites-enabled.
# from http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
# Redirect 80 to 443
server {
  listen 80;
  server_name yourdomain.com;
  return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name yourdomain.com;
    # change the following to wherever you put it
    root /var/www/Baikal-branch-2/web;

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /app.php$is_args$args;
    }
# SSL certs.
  ssl_certificate /etc/nginx/ssl/server.crt;
  ssl_certificate_key /etc/nginx/ssl/server.key;

    # DEV
    # This rule should only be placed on your development environment
    # In production, don't include this and don't deploy app_dev.php or config.php
    location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    # PROD
    location ~ ^/app\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/app.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;
}
evert commented 8 years ago

This issue was moved to fruux/Baikal2#32