Home > OS >  Appwrite with Nginx
Appwrite with Nginx

Time:09-28

I installed Appwrite on an debian-server. The https-port for Appwrite is 444 (443 was already used). Nginx redirects my subdomain to this port. I have a custom SSL-certificate which is working for this domain and subdomains. I can open the appwrite via the subdomain but when I click "Sign Up" to create a root account for appwrite, I get the following Error:

Invalid Origin. Register your new client (appwrite.domain.de) as a new Web platform on your project console dashboard

First I thought I have to set proxy_set_header Host $host; in the server-config, but then I am not able to open Appwrite... instead I get the Error

{"message":"Error: Server Error","code":500,"version":"1.0.1"}

Does someone has another idea or already fixed the same problem?

This is my Server-configuration in Nginx:

server {
server_name appwrite.domain.de;
location / {
    proxy_pass https://localhost:444;
}
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/domain.de_ssl_certificate.cer;
ssl_certificate_key /etc/nginx/ssl/domain.de_private_key.key;
}

server {
    listen 80;
        server_name     domain.de
                        www.domain.de
                        ;
    return 301 https://$host$request_uri;
}

server {
        listen 80;
        listen 443 ssl;
        ssl_certificate /etc/nginx/ssl/domain.de_ssl_certificate.cer;
        ssl_certificate_key /etc/nginx/ssl/domain.de_private_key.key;
        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;
        server_name     domain.de
                        www.domain.de
                        ;
        location / {
                try_files $uri $uri/ =404;
        }

Thanks for the help ;)

CodePudding user response:

You're right, you need to include the proxy_set_header Host $host; directive. You might also want to include the following under server:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;

and the following under location:

add_header       X-Served-By $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto  $scheme;
proxy_set_header X-Forwarded-Host   $host;
proxy_set_header X-Forwarded-Port   $port;
proxy_set_header X-Forwarded-For    $remote_addr;
proxy_set_header X-Real-IP          $remote_addr;
proxy_pass       $forward_scheme://$server:$port$request_uri;

If you're seeing a 500 error, it would be best to check the docker logs for the appwrite container to see what the problem is.

On a side note, if you're looking for an easier way to manage Nginx, I highly recommend Nginx Proxy Manager (NPM). I use NPM in front of my Appwrite.

  • Related