2

So i've had some problems getting SSL to work on my Nginx server. After some time trying and following tutorials i've finally got it to work.

Then when i wanted to access the hipchat server i got suprised with a message that says: "the page isn't redirecting properly".

When i look at the network tab in inspect elements i see the following. Status code: 301 moved permanently.

Before i got SSL to work, the website worked. But after i got SSL working it keeps looping.

Here is the content of my .conf file that i've put in the /etc/nginx/sites-available folder.

            # This is your Hipchat node's DNS name
            upstream chat {
                server hipchat.example.nl:80;    
                keepalive 32;
            }

            # HTTP to HTTPS redirection
            server {
                listen         80;
                server_name    hipchat.example.nl;
                return         301 https://$host$request_uri;
            }

            # 
            server {
                listen                  443;
                server_name             hipchat.example.nl;
                ssl_certificate /example.com.chained.crt;
                ssl_certificate_key /example.com.key;
                ssl on;
                ssl_session_cache  builtin:1000  shared:SSL:10m;
                ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
                ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
                ssl_prefer_server_ciphers on;

                location / {
                    proxy_http_version          1.1;
                    proxy_set_header Connection "";
                    proxy_set_header            Host $host;
                    proxy_set_header            X-Real-IP $remote_addr;
                    proxy_set_header            X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header            X-Forwarded-Proto $scheme;
                    proxy_read_timeout          90;
                    proxy_pass                  http://chat;
                }
            }

This might just be a starters mistake since i've never done anything like this, but can someone help me with fixing this problem?`

edit: So i've just come a little bit further (maybe). But now i cant seem to find the chat. First i've changed my proxy pass to http://127.0.0.1:8095; After that i have restarted nginx, then when i try to connect to the website i get access to a standard Atlassian Crowd page. Which is weird because i am supposed to go to hipchat, which works when i remove all references of SSL.

7
  • 1
    On my experience one possibility is that there is a redirection on the application side to http. Another one is something with "avanced dns" like cloudflare, if you use them Apr 10, 2018 at 10:24
  • Do you mean the "htt p : / /chat;" line in the server block? We do not use any services like cloudfare Apr 10, 2018 at 11:40
  • I don't know if hipchat locally installed has to know that he is on https. If he call himself on http then you have the redirect. Just check for this possibility. The proxy pass is correct Apr 10, 2018 at 12:38
  • It looks like a redirection loop to me - your second server block proxies to the first server block, which then redirects back to the second. Apr 10, 2018 at 12:45
  • Not sure if i understand you correctly Federico, but whenever i go in my browser and type it as an http url, it does redirect me to the https version. But there is still a loop. I just cannot get to the login page of hipchat. Apr 10, 2018 at 13:04

2 Answers 2

0

This is your Hipchat node's DNS name

            upstream chat {
                server hipchat.example.nl:80;
                keepalive 32;
            }

            # HTTP to HTTPS redirection
            server {
                listen         80;
                server_name    hipchat.example.nl;
                location / {
                return         301 https://$server_name$request_uri;
                }
            }

            #
            server {
                listen                  443 ssl;
                ssl on;
                server_name             hipchat.example.nl;
                client_max_body_size 10m;
                ssl_session_timeout 180m;

                location / {
                    proxy_pass                  http://localhost:8080;
                }
            }

It was basically fixed when i changed the proxy pass to localhost and changed my connector in Tomcat's config. Here you can read more about it if you need it guide

0

It was fixed to me when I also configured the tomcat by specifying proxyName, proxyPort, scheme and secure connector properties in server.xml.

My Connector configuration looks like following:

    <Connector port="8080" protocol="HTTP/1.1"
        connectionTimeout="20000"
        enableLookups="false"
        acceptCount="100"
        proxyName="<<your_host_name>>"
        proxyPort="443"
        scheme="https"
        secure="true"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .