簡體   English   中英

Nginx沒有明顯原因一直重定向到HTTPS?

[英]Nginx keeps redirecting to HTTPS for no apparent reason?

我已經設置了Ubuntu VPS,一切都已啟動並運行,但是我一直重定向到不需要的HTTPS。

這是我的配置:

/etc/nginx/nginx.conf

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
    worker_connections 768;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    gzip on;
    gzip_disable "msie6";

    passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
    passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.3.0/ruby;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

/etc/nginx/sites-available/default

server {
        listen 80 default_server;

        server_name www.example.com localhost;
        passenger_enabled on;
        rails_env    staging;
        root         /home/deploy/example.com/current/public;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

這是我對lynx example.com輸出:

Looking up example.com first
Looking up example.com
Making HTTP connection to example.com
Sending HTTP request.
HTTP request sent; waiting for response.
HTTP/1.1 301 Moved Permanently
Data transfer complete
HTTP/1.1 301 Moved Permanently
Using https://example.com/
Looking up example.com
Making HTTPS connection to example.com
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://example.com/

/var/log/nginx/access.log

x.x.x.x - - [25/Apr/2016:09:25:30 +0000] "GET / HTTP/1.0" 301 0 "-" "Lynx/2.8.8rel.2 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/1.0.2g"

有誰知道我為什么一直被重定向?

rails中有一個配置選項可以強制使用SSL。 嘗試設定

config.force_ssl = false

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM