我有一个Django应用程序与postgres后端,我configurationgunicorn后面的nginx作为反向代理工作。 我的机器运行Ubuntu 14.04。 一切似乎都奏效了,除非我尝试login到我的应用程序时遇到了一个令人讨厌的错误: DatabaseError在/ login / inputinettypes的input语法无效:“”LINE 1:… 00101 Firefox / 41.0','2015-12-12 09:39:55.590036 + 00:00','') exception位置:/home/mhb11/.virtualenvs/redditpk/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py执行中,第54行 请注意,如果我单独使用Gunicorn,这个错误永远不会出现! 你能帮我解决这个问题吗? 我有几个念头: 1) inet数据types接受IPv4和IPv6主机和networking(但不包括域名)。 也许我应该改变我在/ etc / nginx / sites-available / myproject中使用的域名? 但我试过了; 我的网站根本无法加载(迄今为止它只在我尝试login后才失败)。 / etc / nginx / sites-available / myproject中的代码粘贴在下面。 2)不同的理论是这样的: 当我尝试login时,我的代码尝试添加一行到空的远程IP的日志表。 当我使用反向代理时,代码可能不知道远程IP,因为它被代理的IP所遮蔽。 由于它是空的,有可能代码试图忽略代理的IP,但没有find更好的。 因此,它应该使用X-Forwarded-For头 。 如果没有合理的IPlogging,程序应该简单地logging“NULL”作为IP。 为此,我在/ etc / nginx / sites-available / myproject中join了proxy_params […]
我们有下面的虚拟服务器设置。 我们希望在访问/doc/ ,nginx会自动访问/doc/index.html ,并使用静态文件/data/doc/site/index.html来提供服务。 server { listen 8123 default_server; access_log /var/log/nginx/test.access.log; error_log /var/log/nginx/test.error.log; # Make site accessible from http://localhost/ server_name localhost; location /doc { root /data/doc/site; index index.html; rewrite /doc(.*) $1 break; } location / { proxy_pass_header Server; proxy_pass http://127.0.0.1:7001; // !!!not exists!!! } } 但, $ curl http://192.168.1.230:8123/doc/ -v * Trying 192.168.1.230… * Connected […]
我刚刚在我的服务器上安装了一个ssl certfificate。 它工作了大约一个小时。 现在该网站没有加载。 当我去做nginx -t我得到这个错误: nginx: [emerg] duplicate upstream "app_server" in /etc/nginx/sites-enabled/rails.save:1 nginx: configuration file /etc/nginx/nginx.conf test failed 这是什么在我的rails.save文件中: upstream app_server { server unix:/var/run/unicorn.sock fail_timeout=0; } server { listen 80; server_name example.com; return 301 https://www.exammple.com$request_uri; } server { listen 80; server_name www.example.com; rewrite ^(.*) https://www.example.com$1 permanent; } server { listen 443 ssl; root /home/rails/example/public; […]
我在Azure中有一个存储帐户。 我有一个容器,我想通过nginx服务的文件。 例如,我得到了位于https://blabla.blob.core.windows.net/dist/index.html和https://blabla.blob.core.windows.net/dist/app.css的index.html和app.css https://blabla.blob.core.windows.net/dist/app.css 我有一个服务器安装程序在'10.0.0.1'上使用nginx进行收听。 当我尝试达到10.0.0.1我希望nginx抓取位于远程存储帐户中的文件。 这是我试图没有成功的: server { listen 80; keepalive_timeout 5; root https://blabla.blob.core.windows.net/dist; …. location / { try_files $uri /index.html; } } 不幸的是,我收到来自nginx的以下错误消息: 2016/01/04 11:37:59 [error] 2192#0: *13 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 10.0.0.10, server: , request: "GET / HTTP/1.1", host: "my-machine-1"
我有这样的configuration: location ~ ^/myway(.*) { rewrite ^/myway(.*)$ /anotherway$1; rewrite_log on; error_log /var/log/nginx/errors notice; } location /anotherway { … internal; } url: site.com/myway/可以正常工作(重写为site.com/anotherway/ )。 但url: site.com/mywayredirect到site.com/anotherway/ 。 为什么? 应该给404错误?
我正在尝试在我的数字海洋实例上设置一个子域名,并且根据我的域名区域文件和我的网站的Nginxconfiguration中的所有内容都是正确的 – 是否有任何显而易见的错误发生? 主域的function,因为它应该 – 它什么都不显示,因为我还没有configuration站点文件。 子域始终转发到我在同一个DO实例上托pipe的另一个域。 DNS区域: $ORIGIN smsteammenus.com. $TTL 1800 smsteammenus.com. IN SOA ns1.digitalocean.com. hostmaster.smsteammenus.com. 1452088962 10800 3600 604800 1800 smsteammenus.com. 1800 IN NS ns1.digitalocean.com. smsteammenus.com. 1800 IN NS ns2.digitalocean.com. smsteammenus.com. 1800 IN NS ns3.digitalocean.com. smsteammenus.com. 1800 IN A **IP address** www.smsteammenus.com. 1800 IN CNAME smsteammenus.com. *.smsteammenus.com. 1800 IN CNAME smsteammenus.com. staging.smsteammenus.com. 1800 […]
我的http块定义了各种gzip规则。 然后,在我已经预先压缩gzip文件的地方,我正在使用gzip_static模块。 即像这样的东西: http { gzip on; #… server { #other vhost rules location /assets/ { gzip_static on; } } } 对于没有启动/断言的URL,nginx会发送头Content-Encoding: gzip 。 然而,像/assets/css/style.css这样的URL肯定会返回一个压缩的响应,但是没有Content-Encoding头。 这是预期的行为? nginx应该如何configuration?
我正在尝试redirect一个特定的URL,如: http://www.domain.com/cadena-de-metas 我正在通过我的configuration文件在/ sites-available / if ( $request_filename ~ cadena-de-metas/ ) { rewrite ^ https://some-other-url.com? permanent; } 这工作,但不幸的是它redirect以及这个url: http://www.domain.com/uploads/descarga-cadena-de-metas.jpg 我怎样才能防止这个?
过去两天我一直在摸索这个问题,我似乎无法得到这个工作。 我正尝试通过nginx为我的网站redirect所有非万维网http和非万维网https连接到www-https。 这是conf。 我正在使用的文件 # Centmin Mod Getting Started Guide # must read http://centminmod.com/getstarted.html # redirect from non-www to www # uncomment, save file and restart Nginx to enable # if unsure use return 302 before using return 301 server { #listen 80; server_name example.com; return 301 $scheme://www.example.com$request_uri; } server { #listen 80; listen 443 […]
我在DNS Made Easy上pipe理两个域domainA.com和domainB.com 。 两个域指向相同的EC2实例。 domainA拥有一个www.domainA.com到domainA.com的HTTPredirectlogging,该logging被删除,并由www.domainA.com到domainA.com的CNAMElogging取代。 domainB.com拥有www.domainB.com到domainB.com的CNAMElogging。 当我去http://domainB.com页面加载正确,但是当我去http://www.domainB.com我redirect到https://www.domainA.com ,注意到安全协议在这里! 我首先想到的是, domainA.com的HTTPredirectlogging被caching,但DNS Made Easy的人指出,执行$ curl -I http://www.domainB.com返回: HTTP/1.1 301 Moved Permanently Content-Type: application/x-msdownload Connection: keep-alive Status: 301 Moved Permanently Location: https://domainA.com/ X-Powered-By: Phusion Passenger 4.0.53 Date: Fri, 08 Jan 2016 19:21:41 GMT Server: nginx/1.6.2 + Phusion Passenger 4.0.53 所以我查看了NGINX的sites-available目录中的domainA.com和domainB.com上configuration的任何HTTPredirect domainA看起来像这样: server { listen 80; listen 443 […]