monicahq / monica

Personal CRM. Remember everything about your friends, family and business relationships.
https://beta.monicahq.com
GNU Affero General Public License v3.0
21.21k stars 2.12k forks source link

working nginx configuration #1050

Closed cmatera closed 4 years ago

cmatera commented 6 years ago

Would anyone be willing to share a working nginx configuration for monica rather than using apache?

Thanks

mbuc commented 6 years ago

I'm also completely unable to get it to work in nginx. Other laravel apps work just fine.

cruisemaniac commented 6 years ago

@cmatera, @mbuc This is mine:

$ cat /etc/nginx/sites-enabled/monica.conf
server {
    server_name  monica.flatty.co;

    root         /var/www/monica/public/;
    index        index.php;
    charset      utf-8;

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

    location ^~ /storage {
        deny all;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include       fastcgi_params;
        fastcgi_pass  unix:/var/run/php/php7.2-fpm.sock;
    include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
   }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/monica.flatty.co/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/monica.flatty.co/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = monica.flatty.co) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen      80;
    server_name  monica.flatty.co;
    return 404; # managed by Certbot

}
zaroth commented 6 years ago

Here's mine. Monica is hosted via docker container on port 13001 (official docker image from the hub).

# vi:syntax=nginx

server {
  listen 80;
  deny all;

  location = /robots.txt {
    allow all;
    alias /var/www/robots-deny.txt;
  }

  # certbot places token files under /.well-known/acme-challenge/ to verify domain and get SSL cert
  location /.well-known/acme-challenge/ {
    root /var/www/certbot/;
    allow all;
    if (!-d "/var/www/certbot/.well-known/acme-challenge") {
      return 403;
    }
  }

  location / {
    return 301 https://$host$request_uri;
  }
}

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

  add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;

  ssl_certificate /etc/letsencrypt/live/monica.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/monica.example.com/privkey.pem;

  include ssl_params.conf;

  location / {
    proxy_pass  http://127.0.0.1:13001;
    proxy_redirect     off;
    proxy_set_header   Host $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Host $server_name;
  }
}
croulibri commented 6 years ago

Hello, People using Monica on Yunohost server (https://github.com/YunoHost-Apps/monica_ynh ) have trouble in using the Android App (see https://github.com/monicahq/chandler/issues/239#issuecomment-401910302 ) We believe it could be linked to yunohost nginx configuration.

Have you tried to connect through Android App ? If yes, does your nginx configuration allow this connection ?

Thanks for your help !

croulibri commented 5 years ago

Hello @zaroth and @cruisemaniac !

People using Monica on Yunohost server (https://github.com/YunoHost-Apps/monica_ynh and https://forum.yunohost.org/t/monica-v2-7-1-personal-relationship-manager/3041/50 ) have trouble in using the Android App (see monicahq/chandler#239 (comment) ), we always get the bad credential message. We believe it could be linked to yunohost nginx configuration.

Have you tried to connect through Android App ? If yes, does your nginx configuration allow this connection ?

Thanks for your help !

zaroth commented 5 years ago

@croulibri I wasn't even aware Monica has an android app, will try it when I have a moment, thanks.

djaiss commented 5 years ago

The app is extremely, extremely limited right now, and has been for a while.

callmesoul commented 5 years ago

I use nginx and copy them

@cmatera,@ ubuc这是我的:

$ cat /etc/nginx/sites-enabled/monica.conf
server {
    server_name  monica.flatty.co;

    root         /var/www/monica/public/;
    index        index.php;
    charset      utf-8;

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

    location ^~ /storage {
        deny all;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include       fastcgi_params;
        fastcgi_pass  unix:/var/run/php/php7.2-fpm.sock;
  include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
   }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/monica.flatty.co/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/monica.flatty.co/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = monica.flatty.co) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen      80;
    server_name  monica.flatty.co;
    return 404; # managed by Certbot

}

but monica server not start . how start minica start

asbiin commented 4 years ago

This is not a Monica issue related, and more a support for ngnix configuration.

anmol26s commented 3 years ago

If there an example of the Apache or Nginx configuration? I am not able to fix the dav on Yunohost for Monica. The Dav redirects to the api page.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.