Can't install Nextcloud on Ubuntu 16.04 with Nginx in subdirectory

So I’m running Ubuntu 16.04 with Nginx on Google Cloud compute engine.

I’ve tried serval method of installation and all failed.

Install with web installer

I remember I’ve successfully installed Nextcloud with this method before on a shared server, though the server is Apache on CentOS 7. But I still go for this method first, but I failed. I tried the Nginx config for installing in a subdirectory from the document and when I visit the installer it returns me 404 (or 502, not sure).

So I change the config to super simple

location /cloud {
    try_files $uri $uri/ =404;

And I did enter the installer, run through the installation process and setup SQL database but then while it redirects me to, it returns 404 Not Found error. (Btw, I’ve tried removing index.php which leads to 403 error.)

Install through archive file

Same it failed, I’ve tried both simple and the document provided nginx config, it all returns me whether 404, 403 or 502 error. And I’ve tried modifying document provided nginx config by changing all nextcloud => cloud since I’ve put the file under cloud, also I’ve tried replacing nextcloud in location => cloud which I didn’t replace the nextcloud if it’s in rewrite.

After all these tries, I’m stuck. Really no idea where can go wrong. I kinda want to try install with snap, but I’m using remote SQL server (Google Cloud SQL), I’m afraid snap will try to use local SQL database.

Who can help me out?