w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Socket.io connection failing when passing through Nginx
There's a special configuration for websockets described on nginx website. You may want to try either of them to see which one works best for you (if works at all). But as noted in Socket.IO wiki, it's best to use HAProxy or Varnish.

Categories : Node Js

nginx rewrite rules failing - causing 503 errors
This isn't a real answer yet, but a rewrite for your redirect block ( until you provide more info on the error log ) Also please verify that the php sock file is actually located at /tmp/website.co.sock change this server { listen *:80; server_name website.co; rewrite ^(.*) http://www.website.co$1 permanent; } to this server { listen 80; server_name website.co; return 301 $scheme://www.website.co$request_uri; } It's more efficent because it doesn't need a rewrite engine.

Categories : Nginx

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

Deploying Django on nginx
Firstly, if you chose to use nginx, then use gunicorn, its the best option out there, and if you so wish to use Apache, then you use mod_wsgi. This will show you how to use gunicorn. Just to tell you how well it serves, gunicorn is used by Instagram, because they claim that it gives them better performance. Setting up gunicorn is very simple and easy to do, and this tutorial here, gives you all the things necessary to make it happen very quickly. This is their website.

Categories : Django

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

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

Nginx+Django From novice to advanced
First of all, you should do choice from FastCGI or WSGI. It's protocols uses for communicates between webserver(Nginx) and application(Django). Secondly, you must install Nginx, may be better from source. Third, you must install python, pip and virtualenv(not necessarily, but for convenience) to the production server. Last, you must run Django as: Example: ./manage.py runfcgi method=prefork socket=/var/run/django.sock pidfile=/var/run/django.pid maxchildren=10 maxspare=10 minspare=2 maxrequest=100 daemonize=true It's all. Then you can set up it. You can use approaches from: Django site DjangoAndNginx Nginx DjangoFastCGI Nginx PythonFlup

Categories : Django

Django's URL regex engine is failing
Here's a clue: The current URL, , didn't match any of these. It should say: The current URL, http://[ip address]/a, didn't match any of these. So the dispatcher isn't getting the request url. Take a look at this solution: Django + NGINX URL Problem

Categories : Regex

Django Unittests Failing Randomly
Please forgive me for stating the obvious. The most common cause for random failure is that one of your tests did not tear down properly. This happens randomly because the order in which the tests are executed is non-deterministic. Try running the failed test alone instead of running the whole test suite. If it passes every time, then it is definitely caused by some other tests. Another possibility is that you may be reusing the old test fixture depending on the arguments you provide to run your tests

Categories : Python

Django login failing after registration
In case login succeeds, your view does not return anything to the client. Views in django must return an HttpResponse object. if user is not None: if user.is_active: login(request, user) print "Login Successful" # (1) Missing return statement here else: return HttpResponse(simplejson.dumps({"login" : "failed"})) # (2) Execution flow falls through to here But you mentioned that the message is in JSON format... Did you submit all the code for your view? It's very likely that the flow of execution just "falls through" to the code that is after the if user is not None statement - which I assume is your User is None case.

Categories : Python

Static files in Nginx, Gunicorn in Django
You got the root and url backwards. Should be: STATIC_ROOT = '/Users/gcarranza/PycharmProjects/clouddemyTest/static/' STATIC_URL = '/static/' And same for media

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

Subdomain hosting with Django + Nginx +Gunicorn
"Using the sites framework" is somehow the same as hosting two projects with the same database. If you would use the sites framework you would have seperate instances for each subdomain which share the same code base and data base, but have to differ in one setting in the first place, which is SITE_ID. If you're able to run multiple instances this for sure has some advantages: You don't need additional processing via a middleware You can easily choose different settings for each site, eg. different template paths, use different middleware etc, even customize urls per project if necessary You're doing already some kind of load-balancing, as you're directing requests to seperate instances, also if one site crashes it shouldn't affect the others If you can only run one instance I guess

Categories : Django

bad gateway on django+gunicorn+nginx configuration
The proxy_pass directive in your nginx server configuration should reflect the upstream server you configured. proxy_pass http://pzw_server; http://wiki.nginx.org/HttpUpstreamModule

Categories : Django

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

Serving static files with Nginx + Gunicorn + Django
You need to create an nginx location block that matches the location of your django STATIC_URL. As you have it configured, nginx is also forwarding requests for static assets to your django application. I'm guessing you are seeing the 404 errors in your django application log? You want nginx to handle these requests, not django. location /static { alias /home/tunde/django-projects/mumu/STATIC/; } Be sure to run the django admin command collectstatic to make sure all the static assets get copied to the STATIC_ROOT directory.

Categories : Django

Avoiding Django's 500 error for not allowed host with Nginx
It depends on your default configuration, but from this answer on ServerFault you must define a default vhost in Nginx, otherwise it will use the first one as a default. Basically, your configuration should look like this in order to allow only requests to "mywebsite.com.br" to pass: server { listen 80 default_server; location / { # or show another site return 403 "Forbidden"; } } server { listen 80; server_name mywebsite.com.br; location / { uwsgi_pass unix:/opt/project/run/brmed_web.sock; include uwsgi_params; } } If you need to also serve up other subdomains (www.mywebsite.com.br, etc.) you can set the server_name to ".mywebsite.com.br".

Categories : Django

Nginx + Supervisor + Gunicorn + Django + Celery - Security concerns
Supervisor will need to be root to start the other processes (like Nginx) with root privileges. That should be fine because Supervisor shouldn't interact directly with external users or accept user input. Gunicorn should be able run without privileges, you may have to change the owner of the unix domain socket it's using to be www-data instead of root. Generally in web server scenarios you need root privileges to access files and open sockets on ports below 1024. If your server can't access files, you should change their permissions rather than run with privileges. You'll generally need privileges to open up port 80 or 443 which is why modern web servers start as root, bind to their port and then shed privileges to their running user of www-data or nobody. In terms of other things yo

Categories : Security

NGINX Reverse Proxy for upstream Django/Gunicorn Backend
Proxy Buffering Generally proxy buffering is only going to help you if you're generating very big web pages, or sending large files. regardless, it's pretty easy to set up, but you will need to tune the buffer sizes to about the size of your largest pages +20% (Any page that doesnt fit in the buffer gets written to disk), or selectively enable proxy buffering on your largest pages. docs: http://wiki.nginx.org/HttpProxyModule#proxy_buffering Caching I don't know much about your app and how dynamic it's content is, but setting up correct Cache Control/ETAG header generation on your app will be the first thing you'll want to look at. This is what will let Nginx know what is safe to proxy. Also, you may wish to setup multiple cache zones to manage the amount of space your caches take on di

Categories : Django

Multiple Django Celery Tasks are trying to save to the same object and failing
I assume you're using django because you tagged it as such. If so, you can use select_for_update (documentation) to lock the objects. This will block the other workers until the transaction completes. If your tasks run a long time you could get timeouts so catch that exception and retry if necessary. from django.db import transaction from celery.task import task @task def mytask(mpk): with transaction.commit_on_success(): my_obj = MyModel.objects.select_for_update().get(pk=mpk) ... Note that this won't work with sqlite.

Categories : Python

Django DetailView failing to find object based on SLUG
Django's slugify method: Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. you are looking for a Camel Case'd tag: http://localhost:9999/tag/RandomTag/ you need to use lowercase: http://localhost:9999/tag/randomtag/ # or `random-tag` depending on the name Check your DB to see exactly how the slug is saved

Categories : Django

Django Path Issues - failing to import module on admin screen load
Assuming the .bash_profile you posted is from your home directory, and you're running apache in the usual way, i.e. as a daemon process started by user root and forking children as user www-data or apache or somesuch, then the PYTHONPATH won't apply to the apache process, so you'll have to configure it separately. If you're using mod_wsgi, then you can add the following apache directive to your webserver config... WSGIPythonPath $HOME/virtual/lib/python2.7/site-packages:$HOME/website/project ...ensuring you substitute $HOME for the full, absolute pathname to your home directory, since it won't be the same for the apache user. Update According to the guide, you should have created a file ~/public_html/dispatch.fcgi, containing something like... #!/usr/local/bin/python2.6 import sy

Categories : Python

serving static files with nginx on diffent machine and gunicorn on a diffrent one for a django production
Please can any one advice me the right way to do this in a production environment. Use a network attached storage (NAS) device that is mounted on both machines. This is how you would do it the right way in production. You could do all sorts of other workarounds - like rsync, nfs, etc. however the most reliable way to have this working is with a proper NAS.

Categories : Django

heroku django - process based on static file path (like nginx config in normal server) or atleast middleware
You can force your django app server serve static content for you by defining custom view and adding it into URLs like this: urlpatterns += patterns('', (r'^static/(?P<path>.*)$', view.MyStaticFilesView.as_view()), ) So now you can get path variable and create your own logic. Just ensure that you return images, texts or any other content with propper content-type. And also you can track __someconstantstring and redirect anywhere you want. This method will cause additional load to your app server.

Categories : Python

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

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

Django Management Form is failing because 'form-TOTAL_FORMS' and 'form-INITIAL_FORMS' aren't correctly populated
Update: After looking through the example you provided there's a snippet that reads like this in forms.py at the end of the add_fields() method: # store the formset in the .nested property form.nested = [ TenantFormset(data = self.data, instance = instance, prefix = 'TENANTS_%s' % pk_value) ] The data argument is causing problems because it's initially empty and internally Django will determine whether or not a form is bound by a conditional that's similar to this: self.is_bound = data is not None # Example >>> my_data = {} >>> my_data is not None True And as you can see an empty dictionary in Python isn't None, so your TenantFormset is treated as a bound form even though it isn't. You could fix it with something like the fo

Categories : Django

Django - Integrating django-profiles (and django-registration) with django-facebook
Here's how I suggest you do things. Do away with django-facebook and look into django-allauth. It will handle accounts (registration, logic, connecting social accounts). Also, django-profiles has many issues with 1.5+ for me and I don't bother with it and instead create my own profiles app and UserProfile model with any additional fields that wouldn't be handled by django-allauth. An example from one of my implementations class UserProfile(models.Model): user = models.OneToOneField(User) default_address = models.OneToOneField(Address, blank=True, null=True) default_tshirt_size = models.CharField(blank=True, null=True, choices=constants.tshirt_sizes, max_length=50) default_shoe_size = models.CharField(blank=True, null=True, choices=constants.shoe_sizes, max_length=50) Y

Categories : Python

Django django-haystack cannot import CategoryBase from django-categories on the first run
Finally managed to fix it!!!! Root cause was in from categories.models import Category in videos app, which is another app model importing the Category which extends CategoryBase, and it's causing circular reference, to fix it, in the models.py of videos app, change from direct import to lazy import as below: categories = models.ManyToManyField('categories.Category', null=True, blank=True) Update: Above fix only worked very briefly and then I got other circular import problems on other models, what finally fixed it was upgrading haystack to v2.1.0

Categories : Django

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

Django-How to make the django inbuilt auth view recognize the customized form
You should override the URL to pass your custom form class as a view keyword argument. Details in How to override a view from an external Django app.

Categories : Python

Django with VS2010 gives me "ImportError: No module named django.core.management" when running
Ok with a lot of fooling around I found this directory: %LOCALAPPDATA%MicrosoftWeb Platform InstallerinstallersPythonDetectInstalls In a mangled sub-folder there is a powershell script DetectPythonInistalls.ps1 that has these two lines for checking if python is installed already: $regKey = "hklm:SOFTWAREPythonPythonCore$pythonVersionInstallPath"; $correctRegKey = "hklm:SOFTWAREWow6432NodePythonPythonCore$pythonVersionInstallPath"; Uninstalling all my pythons did not remove these keys. After removing these registry keys with regedit, WPI allowed me to install its own version of python 2.7 and all the other goodies to go with the Windows Azure Python SDK and it worked.

Categories : Python

Django - How to Authenticate users while logging in (or) registering while using django-bootstrap-toolkit?
In your auth method, if auth_form.is_valid() returns False, you do not return a response object. The same is the case in def register(request): . If it is a GET request, the method does not return a response object. Hence the error(s)

Categories : Django

HTML5 form attributes with Django forms and django-bootstrap-toolkit
You can set the value of the widget.attrs to pass certain other HTML attributes to the form. >>> from django import forms >>> name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',}) >>> name.render('name', 'A name') u'<input title="Your name" type="text" name="name" value="A name" size="10" />' -Django Docs

Categories : Django

Django ajax no refresh:django view without redirecting or refreshing a page
You may want to try the Ajax library for Django project: http://www.dajaxproject.com/ In case you've never heard of Ajax, here's the definition from Wikipedia: Ajax (an acronym for asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client-side to create asynchronous web applications. With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page.

Categories : Python

Subclassing django-registration 1.0 forms for django 1.5 custom user models
Some parts are most definitely not Django 1.5 compatible yet: https://bitbucket.org/ubernostrum/django-registration/src/8f242e35ef7c004e035e54b4bb093c32bf77c29f/registration/forms.py?at=default#cl-48 class RegistrationForm(forms.Form): # ... def clean_username(self): # ... # The line below needs fixing existing = User.objects.filter(username__iexact=self.cleaned_data['username']) if existing.exists(): raise forms.ValidationError(_("A user with that username already exists.")) else: return self.cleaned_data['username'] So unless those methods are changed and/or you subclass them, it won't work yet. For your specific case this registration form should do the trick: from registration import forms as registration_for

Categories : Django

django.contrib.comments.moderation.AlreadyModerated error in zinnia django
I came across this issue too. The way I was able to fix it was to link back to the model_bases folder in the original zinnia package. In my site's 'zinnia' folder (where the updated South migrations are stored): $ ln -sf <python-path>/lib/python2.7/site-packages/zinnia/models_bases .

Categories : Python

Django - Accessing model from django.contrib's User class via ManyToManyKey
There you go: if user.is_authenticated() and story not in liked_stories: In this line the error is thrown. The code you have posted does not resemble the code you are executing.

Categories : Django

How can I order the native django users in the django admin page based on creation time?
Shouldn't it just be: ordering = ['-date_joined'] You can order by any field the model gives you. Since you didn't specify the UserModel you are using, I guess you are talking about the BaseUser? If so, you can order by: first_name last_name id email date_joined username [is_staff] # bool [is_active] # bool

Categories : Python



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