The one click django with ubuntu 16, nginx, and gunicorn is not routing my domain name. When I type the IP address into the address bar it works but when when I use the domain I get 502 Bad Gateway nginx/1.10.3 (Ubuntu). Looking at the nginx error log I see:
2017/10/16 19:05:18 [error] 23017#23017: *80 upstream prematurely closed connection while reading response header from upstream, client: redacted server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/"
I followed the steps here:
https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars#registrar-godaddy
and here:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-host-name-with-digitalocean
But I must have done something wrong. Anyone have any ideas how to solve this. I am brand new to DO, Django, and really web dev.
updating NS servers take up to 48 hours. If you already updated 48 hours ago, then clear browser cache then again access to your domain. Normally after 24 hours, you can access to your domain over the browser. Secondly, check the access to /etc/nginx/sites-available
Your upstream in the nginx configs is wrong, see the nginx log: http://unix:/.... ? It should be either http://... or unix:/... - depends on how your Django setup is configured.
Check your nginx configs in /etc/nginx/sites-available/ or /etc/nginx/conf.d and fix the location of the upstream and reload nginx to fix the issue.
Related
For educational purposes, I am developing a web application, at the moment I am trying to implement a password reset function through a link sent to email. I'm generating a link using url_for and ran into a problem that it creates a link by inserting 'localhost' instead of the github server on which I'm running the application. Of the proposed solutions to this problem, there was only an indication of SERVER_NAME
app.config["SERVER_NAME"] = 'test.test'
but unfortunately, something went wrong, the application now does not start at all and an error appeared:
/usr/local/lib/python3.10/site-packages/flask/app.py:1781: UserWarning: Current server name 'localhost' doesn't match configured server name 'test.test'
return self.url_map.bind_to_environ(
INFO: 127.0.0.1 - - [16/May/2022 17:50:21] "GET / HTTP/1.0" 404 -
I've uwsgi 2.0.19 on Linux running with the python plugin. I serve http(s) traffic with different applications each for a specific record of my managed domain using such kind of configuration to register them to the front uwsgi servers.
subscribe2 = server=x.x.x.x:4443,key=domain.com,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt
subscribe2 = server=x.x.x.x:4443,key=domain.com:443,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt
subscribe2 = server=y.y.y.y:4443,key=domain.com,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt
subscribe2 = server=y.y.y.y:4443,key=domain.com:443,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt
Now when I reach one of the front servers to access a not-existing host, I received such error (the TCP connexion is closed I assume)
curl: (52) Empty reply from server
I would like to be able to have a default/catchall key for such case, that permits to return an HTTP status 404 as I would do in Apache using the _default_ vhost. is it possible.
In order to implement this, you need to define a fallback application using the http-subscription-fallback-key on the front uwsgi server
http-subscription-fallback-key=default
default is a standard application registered on the frontal uwsgi like any other application
subscribe2 = server=x.x.x.x:4443,key=default
subscribe2 = server=x.x.x.x:4443,key=default:80
hi I've been trying for over a month on this..
so, I'm trying to test facebook oauth so have an exact copy of flask oauth login sample code which I put in my ec2 instance bought a domain and registered it on route 53, made an application load balancer and assigned my ec2 in it.
the port... I'm using flask default(5000) and security group setting has inbound port 5000(and others I've tried so far - made it for testing anyways) opened and all traffic on outbound. like this
health check is working perfectly fine. I can see from flask log it's working and returning 200.
but when I type in the domain name it's returning 502 bad gateway and I have no clue what's going on... typing in ip address of the ec2 instance works.. on ec2 instance side where I've turned my app on returns code 400 bad request syntax like this - i have no idea why words are cracked tried changing encoding formats and all failed.
so... I've checked security ports, have checked route53 if I assigned my instance on A-type record set correctly, ec2 instance itself seems to work fine, health check from target groups goes all fine, and I'm out of ideas on where i've done wrong. please help me on this....
stuck on one thing for a long time sure is stressful.. :(
EDIT:
curl -vvv {domain_name} returns:
* Rebuilt URL to: www.*.xyz/
* Trying 1****...
* TCP_NODELAY set
* Connected to www.*.xyz (*) port 80 (#0)
> GET / HTTP/1.1
> Host: www.*.xyz
> User-Agent: curl/7.53.1
> Accept: */*
>
< HTTP/1.1 502 Bad Gateway
< Server: awselb/2.0
< Date: Wed, 28 Mar 2018 10:43:58 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: keep-alive
<
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>
* Connection #0 to host www.*.xyz left intact
EDIT2:
the reason for my bad gateway error was due to my target group was using https protocol. BUT I need this done with https... since oauth(facebook) only works under https....
The 502 Bad Gateway error is an HTTP status code that means that ELB received an invalid response from the EC2 Instance.
I guess you have selected HTTPS in your target group, create a new target group with HTTP and attach it to the load balancer.
I am using python 3.5 & django 1.10 on windows 7 os.
I re-started my laptop today and when I attempt to access my python-django app on my local development server, I now receive the following error:
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[11/Oct/2016 17:16:17] code 400, message Bad request version ('À\x13À')
[11/Oct/2016 17:16:17] You're accessing the development server over HTTPS, but i
t only supports HTTP.
[11/Oct/2016 17:16:17] code 400, message Bad request syntax ('\x16\x03\x01\x00§\
x01\x00\x00£\x03\x03]=Ä)\xa0L\x13\x11\x01;æ\x16:ÅUù\tÓÚß\x0c½\x01z¯êÉú¦ñÚ\x93\x0
0\x00"̨̩Ì\x14Ì\x13À+À/À,À0À\tÀ\x13À')
[11/Oct/2016 17:16:17] You're accessing the development server over HTTPS, but i
t only supports HTTP.
I haven't made any recent changes to the settings.py file, so I am assuming that the settings are not the culprit here, but here are some relevant settings it case it helps solve the issue:
SECURE_SSL_REDIRECT = False
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
I have searched SO and found this post on the subject. The answer suggests that I Switch back to http and that error will disappear.
Does this mean that I should change or enter the url in the browser from https://127.0.0.1:8000/ to http://127.0.0.1:8000/? I am asking this because when I try to do that, the url in the browser automatically reverts to https://127.0.0.1:8000/. I cannot seem to over-ride the https with http.
I have seen this post. I have cleared my browser cache, but the issue continues.
I have run out of ideas.
I would be grateful for any suggestions.
I'm trying to run a project which holds data in web2py server and web2py based client shows the visualization. When running both server and client , the chrome console on clinet side shows:
XMLHttpRequest cannot load http://127.0.0.1:8075/?format=json.
No 'Access-Control- Allow-Origin' header is present on the requested resource.
Origin 'http://127.0.0.1:8080' is therefore not allowed access. (index):1
[ERROR] Cannot connect to data server: http://127.0.0.1:8075?format=json
I'm running above with web2py2.9.5 on linux.
It looks like your web2py client page is served on port 8080 but is then making an Ajax request to port 8075, which violates the same origin policy enforced by web browsers.
If you can't serve both from the same origin, you can get around this by using JSONP or by setting up CORS.