/Edit I done the suggestion of the answer to the question mentioned above to give access rights to the registry as follows:
sudo mkdir -p /usr/local/etc/mono/registry
sudo chmod uog+rw /usr/local/etc/mono/registry
This did not help, as the bad gateway problem only appears after having given access to the registry with the above commands (before that I got the registry error).
Question: I want to deploy a MVC 4 app running on Mono runtime with nginx to an Ubuntu server of Azure. By selecting such a Ubuntu server and running an installer script I managed to have a default web application running and visible on oogstplanner.cloudapp.net. The installer worked as follows:
wget https://bitbucket.org/mindbar/install-mono/raw/master/install-nginx-
mono.sh && sudo chmod +x install-nginx-mono.sh && ./install-nginx-mono.sh
The script installed nginx and mono and setup the nginx.conf and other configuration files.
What I then did was remove this installation, installed postgresql and setup the database, and replaced the files in $HOME/www/ with my own MVC 4 web application which works locally by copying it there. Then when running it I see a
error.
The log file /var/log/nginx/error.log says (for the first and subsequent requests):
2015/04/03 14:24:36 [error] 1305#0: *6 upstream prematurely closed connection while reading response header from upstream, client: my.ip.207, server: localhost, request: "GET /Account/Login?ReturnUrl=%2f HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "oogstplanner.cloudapp.net"
2015/04/03 14:26:05 [error] 1305#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: my.ip.207, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "oogstplanner.cloudapp.net"
2015/04/03 14:29:24 [error] 1305#0: *10 connect() failed (111: Connection refused) while connecting to upstream, client: my.ip.58, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "oogstplanner.cloudapp.net"
(...)
So it does see that it needs to go to /Account/Login?ReturnUrl! Something is working.
When I copy back a default app it works again.
Configuration:
- Here is my /etc/nginx/nginx.conf.
- Here is my /etc/nginx/sites-available/mono-default (same for sites-enabled/monodefault)
/edit I have a strong suspicion that it has to do with the PostgreSQL database. This is because I just rebooted the server, and saw this NullReferenceException being thrown by NauckIt.PostgreSQLProvider:
This error always happens locally once, and then after a refresh the app works. But on the server the app does not work, but after not having the PostgreSQL provider throw a NullReferenceException I get the 502 error. So that is why I think the bad gateway might come from the PostgreSQL connection.
/Edit2 The plot thickens: when I look into the database I see (some) sessions being created in the Sessions table. I don't see any logic when that happens and have been unable to create a new one. But there has been a connection from the web app to the database sometimes.
Here is the PostgreSQL log after a restart (at 14:25:23) and navigating to the website via a browser (at 14:24:36):
2015-04-03 14:24:23 UTC LOG: database system is ready to accept connections
2015-04-03 14:24:23 UTC LOG: autovacuum launcher started
2015-04-03 14:24:23 UTC LOG: incomplete startup packet
2015-04-03 14:24:36 UTC LOG: could not receive data from client: Connection reset by peer
According to a reddit user:
502 Bad Gateway is an HTTP status code and cannot be returned by postgres because postgres doesn't speak HTTP. Similarly, NullReferenceException is a Mono exception and isn't thrown by postgres, so that's not a postgres problem either. Your application is attempting to send some data to postgres but crashes before it can finish doing so. This is an application problem, not a postgres problem. Hope this helps.
Does anyone know what is wrong here?
PS I have all steps I've taken documented under the Deployment part in a README file.