0

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.

  • 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 – Federico Galli Apr 10 '18 at 10:24
  • Do you mean the "htt p : / /chat;" line in the server block? We do not use any services like cloudfare – user7329477 Apr 10 '18 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 – Federico Galli Apr 10 '18 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. – Richard Smith Apr 10 '18 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. – user7329477 Apr 10 '18 at 13:04
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.