Django-Nginx Patch request :405 Method \"METHOD_OTHER\" not allowed - python

I am using django rest framework.
Patch on api endpoint( users/user_id) is working in local django server on my machine. But on nginx development server its showing
{"detail":"Method \"METHOD_OTHER\" not allowed."}
Do we need to change some settings in nginx?

Ok I tried the access the same code from different network and it worked.
Probably it was firewall issue of that particular wifi network.

Related

I am unable to send HTTPS requests from my angular app to my backend

I'm currently using AWS for my backend services and angular for the frontend part. Trying to make my website more secure I added a CA signed SSL certificate on my API gateway and added it to my angular website in my angular.json and package.json.
Whenever I try to access the API using CURL from a linux machine providing it with the certificate and key the API returns a reponse however from my Angular website it always returns ERR_CONNECTION_RESET.
Is there a way to solve this? I'd greatly appreciate any help.
I expected the network layer to be secure and API to return a response. What actually resulted is ERR_CONNECTION_RESET.
first you must be clarify which webserver use are using Nginx or Apache, if you are using an apache web server then try to correct the SSL configuration and Nginx configuration also in case of using.
But according to me, I think you are also using the reverse proxy. First properly configure it. Learn Apache Reverse Proxy and Nginx Reverse Proxy
And finally, you can also check the web server log to get the correct error.

Google Cloud App Engine: How to serve https in a Flexible environment

I work on a python3.6 app that uses flask and oauth2client.
I want to serve https instead of http in gcloud environment.
I tried using talisman-flask:
https://github.com/GoogleCloudPlatform/flask-talisman
However, when I ran their sample app locally I got this error in my browser:
This site can’t provide a secure connection
127.0.0.1 sent an invalid response.
It works fine for http, but can't apparently serve https.
Are there some Talisman configurations I need to change?
Or maybe a whole different solution altogheter?
EDIT:
I changed from debug=True to debug=False and now I get automatically redirected to https but the above error message is still there.
One rather generic approach which can work even with the standard environment local development server (which doesn't support HTTPS) would be to use a reverse proxy.
Such solutions are documented in Appengine - Local dev server with https
It's an old thread, but if you want to serve HTTPS (with or without Talisman) you need, at least, a valid certificate. Please, create one at Let's Encrypt and install in your web server, even if your site are in the web or in your local environment. If you want a good tutorial to help further, I recommend this from Miguel Grinberg, a big "Flask Guru" ;-) .

Using LetsEncrypt / Certbot with django dev server?

I'm trying to implement SSL on my dev server, purely just so I can see it working.
I see from the Certbot page that Certbot works with Apache, Nginx, Haproxy and Plesk.
How would I go about implementing this with Django's dev server? I'm not working in a production environment of any kind yet.
Just to clear something up first: djangos dev server ./manage.py runserver does NOT serve HTTPS, only plain HTTP.
So you should use a webserver (from the ones you mentioned: Apache, Nginx, Haproxy or Plesk) to test you SSL/HTTPS with the certs.
See this post and this code example for ideas to implement SSL with the dev server.
You should create a self signed cert and then you can set up Nginx as a front facing webserver for your uWSGI Django app.

API timeout in nginx but the same work in local server Django WSGI

I am facing issue in my Django app...
which is working fine in mhy local django WSGI based server. but the same facing timeout in nginx..
what will be the issue?
is there anything to deal with increasing nginx process?
my nginx response which took 30000ms to respond in my server but without data (i am using AWS),
my local got respond in 12000ms with response,
any help?
My django app is on AWS i am using nginx gunicorn and supervisor for deployment configuration...
I'd recommend against fiddling with the Nginx and Gunicorn config.
Instead try reducing the amount of data you're trying to fetch in a single API response. If you're data is in the form of a list [which it looks like from the picture] I'd recommend paginating your response. Django has excellent pagination module which can be used.
https://docs.djangoproject.com/en/2.0/topics/pagination/

Django + alwaysdata.com Noob Question

I'm learning Django and working on sample sites.. I registered at alwaysdata but am unable to view the site after I go 'manage.py runserver' in the SSH (this is after I've created the project and navigated to the appropriate directory, of course).
I appreciate any help.
Thanks
Have you taken a look at the wiki entry regarding the django dev server? Google translate seems to indicate that you need to request some ports open first, and that once you've got them assigned you can pass in one of those port numbers to runserver to run it on that port.
If you need the translated-to-English version, here's a link
I am also an alwaysdata customer. Daniel DiPaolo gave you the right links to get it working on ssh with the dev server. The google translation seems correct to me. You need to request a port range in order to use the dev server on ssh.
But this is intended only for debugging purpose and should run for a short while.
Here is how to deploy with fastCGI which is the regular way to deploy a Django site on alwaysdata.
http://wiki.alwaysdata.com/wiki/D%C3%A9ployer_une_application_Django.
Google give a decent translation
AlwaysData is running a forum at http://forum.alwaysdata.com/ mostly in French but questions in English are welcomed.
The devserver included with django is for testing purposes, only on your local machine and should not be used on a web host. From the docs:
DO NOT USE THIS SERVER IN A PRODUCTION
SETTING. It has not gone through
security audits or performance tests.
(And that's how it's gonna stay. We're
in the business of making Web
frameworks, not Web servers, so
improving this server to be able to
handle a production environment is
outside the scope of Django.)
If i have somehow misinterpreted your question, i apologise.
When you enter manage.py runserver you're running the development web server on the loopback interface (127.0.0.1). You could test this out by running wget 127.0.0.1 on the same server that the development web server is running.
If you want it to be on the internet so you could access it from outside that server, you'd have to specify your public ip. For example, to run the web development server on ip 1.1.1.1 and port 8080 (personally recommend using a non-standard port):
manage.py runserver 1.1.1.1:8080
To find out your public ip, try running ifconfig on SSH.
Also, you might have to check out the firewall settings with your ISP/server provider.

Categories

Resources