nginx with mod_wsgi - nginx

I generally run web apps behind nginx with FastCGI. I wanted to experiment with mod_wsgi, however it seems quite out of date. The author mentions that it worked on version 0.5.34, however I'm running 0.7.62 now.
The wiki article warns of compilation problems with the module and later versions of nginx. Has anybody used mod_wsgi with more recent versions of nginx? Is there another module out there that I'm missing?

For nginx other options are FASTCGI, Phusion Passenger or proxying. You could also just use the original mod_wsgi with Apache instead, fronting it with nginx for static file handling if necessary.
For nginx/mod_wsgi ensure you read:
http://blog.dscpl.com.au/2009/05/blocking-requests-and-nginx-version-of.html

I'm setting this up too, and I'm just curious - why not reverse-proxy nginx to a multi-threaded paste wsgi process?

Related

Curl error 7 when installing apps on nextcloud

Hey this is my first question on here, so go easy.
I set up a Nextcloud server on my homelab in an ubuntu server 20.04 vm using the snap install. I have a seperate vm running nginx as a reverse proxy to my Nextcloud instance. Everything works flawlessly as intended, except that when I try and install apps on Nextcloud, I get a curl error #7. I've tried using my lan ip through the web ui, my public domain name through the web ui, and the commandline using the nextcloud.occ app:install command. I always get the same error. I tried to find the appropriate log file to get more information but looking in /var/snap/nextcloud/current/log/ I couldn't find any relevant info in any of the logs. Running php -m comes up with php not installed, I guess because php is installed via the Nextcloud snap? Obviously php is installed somewhere because Nextcloud is running, but I don't know how to look and see what modules are enabled, or how to install new ones using the snap. Any help on what to do is much appreciated!
enter image description here
Update: I fixed it. I think I had improperly configured my firewall, and turning it off (in proxmox)/making some changes to my /etc/netplan/*.yaml file to properly configure the static IP fixed it. GL
Another reason can be a wrongliy configured network. I forgot to set the gateway/proxy for IPv4, so github.com was unreachable. Most other services I use seem to resolve IPv6 first, so I did not have any other problems besides updating nextcloud apps.

Can a Polymer 2.0 PWA be served over HTTPS?

I am trying to build my first progressive web app, using the Polymer CLI. I am trying to make my app to load an NPM package, but the console was showing an error when loading it. I think I resolved this issue by moving the dependency into a different directory, as I no longer receive that error in the console. However, my package still isn't executing it's intended purpose. I think this is because polymer serve serves on HTTP by default, while my package seems to require HTTPS. I looked at these articles on the polymer website (https://developers.google.com/web/updates/2014/11/Support-for-installable-web-apps-with-webapp-manifest-in-chrome-38-for-Android , https://www.polymer-project.org/2.0/toolbox/), but they don't seem to refer to HTTPS at all. Am I on a wild goose chase, trying to serve over HTTPS?
Yes, Polymer apps can run over HTTPS. The documentation just needs to be updated. You might find something useful in the polyserve README or in running polymer --help.
As of version 0.4.0, you can use the -P flag of polymer-cli to enable HTTPS:
polymer serve -P https
or enable HTTP2 (uses HTTPS, requires Node 5 or newer) with:
polymer serve -P h2

Running a Go webserver behind Phusion Passenger

Phusion Passenger has a great ecosystem for running webapps behind a webserver. I have experience with it from Ruby and Node.js apps. Now I rewrote a webservice to use Go, and it's time to deploy it. It seems natural to put Passenger+Nginx in front of the go webserver (using net/http). Searching around it seems that nobody has tried this, or asked about this anywhere...
I can't seem to find a configuration option to attach a custom binary, instead of passenger_ruby/passenger_node etc.
Can (should?) I use Phusion Passenger to run my binary created using go build?
No, you can't. Passenger doesn't actually use HTTP internally; it uses a custom protocol (like FastCGI or SCGI but incompatible with both) to communicate with your app and requires its own code in the application for management and dispatching requests. They don't provide such support code for Go.
This is actually possible now, Passenger 6 has added generic language support. You can find the tutorial here: https://www.phusionpassenger.com/docs/advanced_guides/gls/go.html
Basically:
Compile your Go program and put the binary somewhere convenient. The application needs to accept configuration to choose what port to run on.
passenger start --app-start-command 'env PORT=$PORT ./main' assuming main is your program name.
Passenger will try to tell the application what port to start on so that it can have port 80/443.

Why use nginx to deploy tornado instead of its built-in server?

I found out that we can run the tornado application from just firing something like python main.py. But everyone else says to deploy tornado with nginx. What are the benefits? I know it's a bit foolish, but I really am confused.
See the notes on Nginx in the Tornado docs:
http://tornado.readthedocs.org/en/stable/guide/running.html
Since one Tornado process can only take advantage of one CPU core (Edit: See updated docs for a development on this), use Nginx to load-balance multiple Tornado processes to use multiple cores
Additionally, Nginx is likely a more efficient static file handler than Tornado.

mod_mono: Random CompilationException errors

After a server restart I sometimes get random CompilationException errors like this:
CompilationException: CS0006: Metadata file `/tmp/apache-temp-aspnet-0/ca373c84/assembly/shadow/10cad1cb/02cb7ade_1201ab15_00000001/ZedGraph.dll' could not be found -> HttpException: Single file build failed
and you can't access the application. If I restart the server again then the problem disappears.
The file that triggers the error can be one of my own dll's or a dependency, like mysql.dll for instance.
I am using mono 2.10.2, CentOS release 5.7 (Final), Apache and mod_mono on a Linode VPS.
Any idea of what can be the cause?
Edit: Since my troubles started when I moved to Linode and they use XEN, I have found the option --with-xen_opt=yes that looks promissing:
http://mono-project.com/Advanced_Mono_Compile_Options
Sounds like a bug (race condition?) with the shadow copying and compilation. There have been others found and fixed before... see http://grendello.blogspot.com/2007/08/new-modmono-and-xsp-developments.html
And this is a report of a similar problem in 2006 http://lists.ximian.com/pipermail/mono-list/2006-March/030970.html
Rather than rebooting the system, you can try restarting apache. Note, I have found it can help to stop apache and then start, rather than a restart.
You can also enable the mod_mono control panel and restart the application from there. Add this in apache config.
<Location /monocp>
SetHandler mono-ctrl
Order deny,allow
Deny from all
Allow from 127.0.0.1 <YOURIP>
</Location>
To automate this process take a look at Monit.
FWIW, I had the exact same issue on a dedicated server with no virtualization (8 core i7, x86 Ubuntu Server Edition), so I do not believe this to be a Xen-induced issue. For either the OP (SCL) or anyone else with this issue, I have documented my work around in another SO post here, as well as having filed a bug report with Mono/Xamarin.
It does seem to be a race condition, but not related to virtualization.
It seems that the problems where caused by XEN virtualization and mono precompiled binaries. I compiled mono with the option --with-xen_opt=yes but I wasn't able to compile XSP so I couldn't test if that solved it for sure but I moved exactly the same application to a dedicated server and after 2 million requests I didn't experience any error.
Update: Check Mahmoud answer

Resources