DEV Community

Using HTTPS in docker for local development

Vishal Raj on May 13, 2021

As a web application developer, one of the most common challenge faced is, not having the local development environment close enough to the pro...
Collapse
 
rubendob profile image
rubendob

Ey men

thanks for your tutorial. Was useful to me cause I want to test Wordpress API Rest locally with some Python code and I think HTTPS is mandatory to that scenario so kudos on that.

I have to debug just a little cause I have 502 from proxy but I was able to fix it.

Regards

Collapse
 
rpino profile image
Rafael

Hi, how did you fix it?

Collapse
 
dreamerworks profile image
dreamerworks • Edited

Thanks, I'm currently evaluating the use of a docker proxy nginx that forwards requests to several php:apache dockers. On the wordpress idea in this article, we say that from nginx to wordpress the connection is http (80), it is only https (443) from the host to the proxy. This is a common scenario and fine from a setup perspective.
My question is, in wordpress (and some other softwares) we need to specify in some field the blog url and I would put there something like https://blog url. This causes the site to be configured to run in https but the requests are coming to http(80) from the proxy.
Is this a problem and the whole path should be https? could we put the certificates on apache/wordpress and use the nginx as a pure proxy just forwarding the 443 requests?

Collapse
 
altela profile image
Altela Eleviansyah Pramardhika

working amazingly well, thanks

In case someone is having error during docker-compose up after configuring nginx, try to open the nginx.conf and add } (closing curly braces) at the end.

Also, let the ssl_certificate and ssl_certificate_key path in nginx.conf file as it is. It is actually path of nginx.conf inside the docker. You just need to put the .crt and .key inside certs folder

Collapse
 
gorynych profile image
Stepan Mozyra

Install something locally to be able to play with docker? ))) C'mon

Collapse
 
vishalraj82 profile image
Vishal Raj

Well, its only facilitating the development. Dont' you install docker as well?

Collapse
 
gorynych profile image
Stepan Mozyra

Yeah... I'm also install OS on my machine before installing Docker, and all of these are installed on top of hardware manufacturer's BIOS, installed on motherboard chips )). But I really hope you understand the difference ;)

Thread Thread
 
raymondpeterfellow profile image
Seb

💩

Collapse
 
alastairmeasures profile image
Alastair Measures

Thank you - great article.

Good to see Alpine being used.

Will definitely reread the SSL section.

Collapse
 
sebastian_fehlandt profile image
Sebastián Fehlandt

Hi

Thank you for this. I did it and it works but the static files are being served in the url of the docker-service. E.g:

wordpress/wp-admin/css/install.min...

Which of course is not reachable since port 80 is assigned to the proxy service.

Did you have this problem? How can it be fixed?

Collapse
 
pjaws profile image
Paul Matthew Jaworski

Can you explain the proxy_pass line? I'm a little confused about what the upstream is supposed to be there for non-Wordpress apps.

Collapse
 
pjaws profile image
Paul Matthew Jaworski

Figured it out. Looks like it just needs to be the name of the app service.

Collapse
 
stalukder03 profile image
Sajib Talukder

It did not work for me, OS is Ubuntu. Could you please help to get rid of this issue?

Image description

Collapse
 
ooosys profile image
oOosys • Edited

Have you checked the connection? Have you checked the proxy and the firewall? Have you checked if hello.test is equipped with all it needs?
Try to ask the same on stackoverflow to see why your question is not detailed enough to be a good question there (e.g. you haven't provided the code and full details, so that others can reproduce your problem).