4

I have two docker containers:

  1. One container runs my spring boot application which listens on port 8080: This container exposes 8080 port to other docker containers. Container ip in the docker network is 172.17.0.2.
  2. The other container runs nginx which publishes port 80.

I can successfully put my spring boot app behind nginx with the following conf in my nginx container:

server {

server_name <my-ip>;

listen 80;

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

}

Doing a GET request to my REST API (http://my-ip/context-url) works fine.

I am trying now to put my application behind nginx with https. My nginx conf is as follows:

server {

    server_name <my-ip>;

    listen 80;

    return 301 https://$server_name$request_uri;

}

server {

   server_name <my-ip>;

   listen 443;

   ssl on;
   ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
   ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

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

However I cannot access my application now either through http or https. http redirects to https and result is ERR_CONNECTION_REFUSED

2
  • 1
    Are you sure that your nginx is restarting? Test the configuration using nginx -T. IDK if you can build a secure server using its IP address as a name. Commented Apr 21, 2018 at 11:43
  • I don't need to restart it. I do nginx reload and configuration changes. Commented Apr 21, 2018 at 20:55

1 Answer 1

0

Problem was that I was not publishing 443 port when running nginx container but only port 80.The nginx configuration is right.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.