w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Difference between nginx module and uWSGI plugin
To be nginx-friendly a module must be non-blocking and must not use calls like fork(). If you can write a nginx module like this, use the nginx approach. The problem is that all of the current available nginx modules for mongodb are blocking (they generally use threadpools but can potentially blocks). The only solution would be reimplementing the mongodb protocol (check this project http://mojolicio.us/perldoc/Mango) without using the currently available libraries. On the other side uWSGI has not such limits (it can use processes, threads and coroutines), and a gridfs module is already available: http://uwsgi-docs.readthedocs.org/en/latest/GridFS.html The problem is that there is no doc about writing uwsgi plugins, so you have to base yourself on the current available ones Btw, you ne

Categories : Nginx

Django, nginx and uWSGI caching results until uWSGI/MySQL restart
I had the same behavior and found this post https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k Adding this line on settings.py (only the OPTIONS key) on Django: DATABASES = { 'default': { 'OPTIONS': { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED", } } } seems to have resolved the problem.

Categories : Mysql

Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

nginx loadbalancing in uwsgi
The first approach is a lot saner and avoids nginx to pass requests to a worker already busy. You may find some blog posts or doc about the thundering herd problem, i suggest you to read this: http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html basically unless you are on very specific needs (and limits) the first approach is the way to go.

Categories : Nginx

Setting up django with uwsgi and nginx
ImportError: Import by filename is not supported. The --module directive expect a module, not a file. You should use --wsgi-file instead.

Categories : Python

Django app with Nginx + uWSGI on Amazon EC2
Simple Example used FastCGI Deamon in Amazon EC2 django.sh -> https://gist.github.com/romuloigor/5707566 nginx.conf -> https://gist.github.com/romuloigor/5707527

Categories : Django

nginx, django -- uwsgi does not see POST data
x=request.body This should be the first line in any django app ran by wsgi. Then POST DATA works. Django just must read the body of request immediately if it is used later. However, there still is this problem: invalid uwsgi request (current strsize: 16705). skip. So I it is difficult to use uwsgi in this setting. I solved this by the use of fcgi, which does not have such limits. Justification: strsize is not configurable -- http://comments.gmane.org/gmane.comp.python.wsgi.uwsgi.general/5712 Edit: Roberto is right -- strsize is unrelated to request's body and it WORKS even in uwsgi. Debugging a problem during travelling, nights etc is not always a good idea ;) However, Django must read the body request immediately and this is beyond doubt. The request's body must be read prior doing a

Categories : Python

Python: uWSGI configuration for NGINX+FLASK
This question is popular now, so I've improved this answer a bit. I've moved the most important points from the comments. Yep, that's the normal behavior. Nginx's master process needs root privileges to manage listening sockets on the machine. This forum thread states that you can change it, but it may cause problems. However, Nginx does allow to change the owner of the worker processes. It depends on how the uWSGI was installed. If uWSGI was installed via apt-get you can start (stop, restart) like this: service uwsgi <action> You installed uWSGI via pip, so the daemonize option will do the trick: /path/to/uwsgi --daemonize /path/to/logfile You can start it under any user you want, BUT if you decide to run it under root, you should specify the gid and uid options. uWSGI's bes

Categories : Python

How to track down a Python/Django/uwsgi/nginx timeout
You have a pretty "strange" setup: nginx -> uwsgi http router -> uwsgi instead of nginx -> uwsgi maybe you have some good reason for it, but in such a case you need to set the timeout between uwsgi http router and uwsgi via --http-timeout 1800 If the http router is not you want/need you can just let uwsgi speaks http with the --http-socket option

Categories : Python

502 Bad Gateway error Nginx and uWSGI in deploying Flask app
With uwsgi_pass 127.0.0.1:9001; you declared to Nginx your intent to talk to uWSGI through TCP socket, but have not warned uWSGI about it. Try adding a corresponding socket line to your /etc/default/uwsgi file: PYTHONPATH=/var/www/reframeit-im MODULE=wsgi socket=127.0.0.1:9001

Categories : Nginx

Nginx+bottle+uwsgi Server returning 404 on every request
Are you sure that NGINX and UWSGI are working properly? Lot's of things could be wrong, I recommend you to follow this guide: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html It's a step by step to setup NGINX and UWSGI with Django but I'm pretty sure you can apply it to any other web app than Django.

Categories : Python

Flask + uwsgi + nginx + debug. 502 error instead of debugger page
Flask debug=True does not work when going through uWSGI may help. Essentially, uwsgi is not intended for development environments where you want debugging info in the browser. It's a production server. possibly adding in app.debug = true may help, after you have instantiated the Flask object, but otherwise, to get a proper debugger, use the flask internal server for development.

Categories : Nginx

Mongodb replica set auto reconect don't work after down and up for nginx + uwsgi with several processes
After a change in your replica set (no primary, new primary, etc.), the next operation will throw an AutoReconnect exception. After that one failed operation, the underlying PyMongo MongoReplicaSetClient will reconnect to the replica set, and future operations may succeed. If there is a new primary, MongoReplicaSetClient will find it and future operations will succeed. If there is no primary, no operations can succeed unless you set your ReadPreference to PRIMARY_PREFERRED. See the docs here: http://mongoengine-odm.readthedocs.org/en/latest/guide/connecting.html#replicasets The reconnection process must happen once per uwsgi process. So if there is a change to your replica set, you can expect one AutoReconnect exception per uwsgi process.

Categories : Python

Restarting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable
Passenger takes what you set in the file nginx.conf by passenger_ruby, for example: passenger_root /home/dev/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.5; passenger_ruby /home/dev/.rvm/wrappers/ruby-1.9.3-p448/ruby;

Categories : Ruby

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass http://127.0.0.1:81; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass http://127.0.0.1:81; } In apache you create a virtual host <Virtua

Categories : Apache

Python bottle vs uwsgi/bottle vs nginx/uwsgi/bottle
Flask vs Bottle comes down to a couple of things for me. How simple is the app. If it is very simple, then bottle is my choice. If not, then I got with Flask. The fact that bottle is a single file makes it incredibly simple to deploy with by just including the file in our source. But the fact that bottle is a single file should be a pretty good indication that it does not implement the full wsgi spec and all of its edge cases. What does the app do. If it is going to have to render anything other than Python->JSON then I go with Flask for its built in support of Jinja2. If I need to do authentication and/or authorization then Flask has some pretty good extensions already for handling those requirements. If I need to do caching, again, Flask-Cache exists and does a pretty good job w

Categories : Python

get ip and url from ngx_http_request_t in nginx module
A ngx_http_request_t is a typedef for ngx_http_request_s. See http://lxr.nginx.org/source/src/http/ngx_http.h#0016. It looks as follows (from http://lxr.nginx.org/source/src/http/ngx_http_request.h#0358): 0358 struct ngx_http_request_s { 0359 uint32_t signature; /* "HTTP" */ 0360 0361 ngx_connection_t *connection; 0362 0363 void **ctx; 0364 void **main_conf; 0365 void **srv_conf; 0366 void **loc_conf; 0367 0368 ngx_http_event_handler_pt read_event_handler; 0369 ngx_http_event_handler_pt write_event_handler; ... 0394 ngx_str_t request_line; 0395 ngx_str

Categories : C

Logging a variable set by nginx's Lua module
You need to define the variable $foo before the Lua module can use it. Check the doc for an example defining the variable within the location directive before utilizing it.

Categories : Nginx

nginx rewrite module not working?
You seem to have mixed different bits from different how-to's, without understanding them. Observe: rewrite ^(.*)$ index.php?/$1 last; #question mark, typo? location ~ .php$ # matches end of request_uri fastcgi_split_path_info ^(.+.php)(/.+)$; # matches .php followed by a slash For the third statement to match, .php is never at end of request_uri, so this statement will never match in this location. Remove the question mark from the first statement, remove the dollar sign from the location. Then add: fastcgi_param SCRIPT_FILENAME $document_root$ fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_split_pathinfo; to the location block. Try to understand from the documentation and try to further restrict the location block.

Categories : Nginx

error on installing passenger nginx module on ubuntu with ruby 2.0.0 via rvm
You have to install development tools first. Most likely you're missing some libraries just like the error is indicating. I ran into the same thing a couple weeks back. Here is a nice tutorial similar to the one that helped me out. http://alexpearce.me/2012/06/setting-up-a-vps/ With a little bit of luck, I believe that this line will solve your current issues, but be sure to look over the whole document. sudo apt-get -y install curl git-core python-software-properties build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libcurl4-openssl-dev Also: I've also always had troubles when using rvm and have found that rbenv works with less hiccups, which is actually mentioned in this tutorial. For databases, if you aren't using postgres then you should be able to just swap out the

Categories : Ruby On Rails

nginx + passenger + rails: do I need to start the rails server or just start nginx?
Set nginx to forward to my rails server using this https://gist.github.com/jeffrafter/1229497 worker_processes 1; error_log /usr/local/var/log/nginx.error.log; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream dev { server 127.0.0.1:3000; } server { listen 80; # You could put a server_name directive here (or multiple) if # you have not setup wildcard DNS for *.dev domains # See http://jessedearing.com/nodes/9-setting-up-wildcard-subdomains-on-os-x-10-6 # If we choose a root, then we can't switch things around easily # Using /dev/null means that static assets are served through

Categories : Ruby On Rails

nginx and ssl certificate
This is the .cer file, the .key is the key you used to produce this .cer file, try to remember how you got this .cer file, you probably generated a key file on your device, then created a certificate signing request out of it .csr and then uploaded it to get this certificate correct ? you should already have the key file.

Categories : Ssl

PHP htaccess to nginx
@Harinder: There must be some RewriteCond based on which you're applying this RewiteRule The reason why i am saying this is that, according to your RewriteRule RewriteRule ^(.*)$ /all_drivers.php?id=$1 [QSA] whatever that comes as a request, you are sending it to all_drivers.php. And if this is the desired rule, then all the request, no matter what will be send to this file only. Also it will be nice if you give us the complete .htaccess code segment that you want to be translated. And please check if you have configured php execution block correctly with all the required fastcgi directives as this blank php's output comes in the case if you have not passed SCRIPT_FILENAME fastcgi directive.

Categories : PHP

htaccess to nginx (help)
Please try the following: server { listen 80; server_name www.website.com; return 301 $scheme://website.com; } server { listen 80; server_name website.com; root /path/to/root; location / { try_files $uri @rewrite; } location @rewrite { rewrite ^/([a-z]+)/?([0-9a-zA-Z]*)/?.*$ /index.php?a=$1&q=$2 last; } }

Categories : Apache

Nginx and Unicorn Set up Not sure what I am doing
I've never used knife... It might be worth checking out this this blog post about setting up Capistrano, Nginx, and Unicorn - I've always found Capistrano to be a good deployment app (and there's lots of support for it, especially on SO). On Heroku, you don't deploy as you would with Capistrano or any other deployment utility - you simply push to a branch on your Heroku server. See: https://devcenter.heroku.com/articles/git for how to deploy on Heroku using Git.

Categories : Ruby On Rails

Nginx add sites
well if you're going to use only 1 IP, then it's 1 server block ( 1 virtual host ) server { server_name [domain name or ip]; index index.html; # or php or whatever location /foo { root /var/www/foo/public_html; try_files $uri $uri/; } location /bar { root /srv/www/bar/public_html; try_files $uri $uri/; } } You haven't mentioned what kind of application this is, so it probably need some changes depending if its a php site or rails or any thing else, this would work for static content only like html and images.

Categories : Nginx

Regex for Nginx
The way you written it means that the / is the one that could appear multiple times, ie /home///////share, to fix it write soemthing like location ~ /home/[^/]+/share { }

Categories : Regex

When do I need to restart nginx
Probably only when you change its configuration, if you are referring to when your django code changes you have to restart the uwsgi server, usually "touch"ing the wsgi.py file is enough to instruct the uwsgi server. Changes in static files don't require the uwsgi restart (because you usually serve them directly with nginx), and if you don't use cached template loaders, but only the default filesystem loader, you don't require the restart when changing a template either. Note that the cached template loader is usually suggested in production.

Categories : Django

Redirecting to SSL using nginx
In order to use regular expressions for matching locations, you need to prefix the expression with either ~ or ~*: if ($server_port = 80) { location ~ (en|fr)/shop { rewrite ^ https://$host$request_uri permanent; } } From the documentation: To use regular expressions, you must use a prefix: "~" for case sensitive matching "~*" for case insensitive matching Since nginx does't allow location blocks to be nested inside of if blocks, try the following configuration: if ($server_port = 80) { rewrite ^/(en|fr)/shop https://$host$request_uri permanent; }

Categories : Nginx

Upgrading Nginx 1.1.9 to 1.4.x
This is what test environments or virtual machines are made for. Your question is quite general and hard to answer this way. Try it out in a test setup. If you don't have that option, read the Changelog. From my experience, I haven't encountered backwards compatibility issues with configurations since 1.0 (before that even, but that's when officially configuration syntax should be considered stable). That's not to say there aren't any.

Categories : Ubuntu

Git on server with nginx
You need a web frontend for git. Have a look at https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools#Web_Interfaces for an overview

Categories : GIT

How to use nginx proxy_pass
Try the nginx HttpRewriteModule you dont need a proxy for these(tho). it follows this format: rewrite regex replacement flag | | | | rewrite ^/ http://www.example.com/image/file.aspx?img=1 permanent; Then: location / { rewrite ^/ http://www.example.com/image/file.aspx?img=1 permanent; }

Categories : Node Js

Unknown error nginx
You can only specify options for the listen directive once per combination of host:port (see the documentation). The error is being caused by this line in your second file: listen [::]:80 ipv6only=on; Because the first file has the ipv6only=on option, the second file does not need it. Changing the beginning of the second file to the following should fix the problem: server { listen 80; listen [::]:80; ... }

Categories : Nginx

Symfony2 and nginx web host
Clear your app/logs and app/cache directories and give your web server permissions to write to them (read the installation chapter). You left there some files from your development machine.

Categories : Symfony2

I'm trying to rewrite a sef url into a plain url using nginx
you probably need to add a break at the end of the line rewrite ^/tools/app/(.*)$ /tools/app?action=$1 break;

Categories : PHP

nginx add_header not working
What does your nginx error log say? Do you know which add_header lines are breaking the configuration? If not, comment them all out then enable them 1 by 1, reloading nginx to see which one(s) is/are the problem. I would begin by commenting out the block: add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; add_header PS 1 The problem could be that you're setting headers not supported by the core httpHeaders module. Installing the NginxHttpHeadersMoreModule may be helpful. Also, try replacing the two add_header lines int the location ~*

Categories : PHP

How can I hide if I was using nginx or apache2
There are 2 ways to do this. You can modify the source of nginx and changing the server signature in the source, recompiling and installing from there. Alternatively you can add a module called headers-more-nginx-module This then allows you to modify the headers without recompiling each time you wish to change the headers. http://wiki.nginx.org/NginxHttpHeadersMoreModule#more_set_headers Both of these do however require recompiling ngnx and reinstalling.

Categories : Nginx

Running CKAN behind Nginx
The default installation of CKAN (the one done via package install) sets up CKAN running on Apache with mod_wsgi with Nginx on top. Have at look at the Apache and Nginx configuration files for details on how it is done. Regarding using paster on a production environment, I'd imagine that sooner or later you will hit performance problems, so I would avoid it. You may find this answer useful: Can I use paster on production site?

Categories : Nginx

chef not loading nginx
Are you using a cookbook manager such as Berkshelf? If not, you should look into that, it can assist you with this problem. (I'm not familiar with chefFile, perhaps this is a cookbook manager). A (not so ideal) option to solve this would be to manually clone the nginx cookbook repo and put it in chef/cookbooks or chef/cookbooks-sources and this would solve your problem.

Categories : Nginx

Nginx can ping itself but cannot connect from anywhere else
To connect using the IP address add the IP to the server name server_name server.com 192.168.1.101; Then restart nginx and it should work if you access http://192.168.1.101 from inside the local network.

Categories : Nginx



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.