Chemical-Curation / chemcurator_django

Backend services for chemical curation
https://api.chemreg.epa.gov
MIT License
1 stars 0 forks source link

ports in related resource urls #260

Closed cmgrulke closed 3 years ago

cmgrulke commented 3 years ago

As a user I want the related urls I am receiving in links under the api not include ports So that because I as a user should not know what a port is

Acceptance Criteria: All URLs and Aliases returned in responses will match. If I am told the API is deployed at "https://ccte-api-chemreg-stg.epa.gov/" links in the API response should not direct me to "http://ccte-api-chemreg-stg.epa.gov:8000" image

Test:

scaduto commented 3 years ago

@cmgrulke @dmlyons2

While I have been able to replicate this issue after a ton of configuration and finagling with docker/my own network, I am unable to find a resolution for it. After testing and speaking with other teammates, I believe that the issue that is occurring is solely a DevOps one and not an issue with our codebase.

The research that I have done has led me to believe that the gunicorn container is being hit directly and that there is an issue with the ports being properly opened for apache. I have made a few changes to the docker-compose file that was in the wiki with no luck. With a limited testing environment that I cannot be completely certain is equivalent to the way that Dave is building out production, and limited knowledge of gunicorn/apache I am unable to continue forward solely working this ticket. I would be happy to assist whomever picks it up next. I will attach some resources that I found helpful and my docker-compose file below.

Some additional research that I've done:

https://docs.docker.com/compose/networking/ https://serverfault.com/questions/960131/nginx-docker-and-gunicorn-url-without-the-port-number-in-the-url https://levelup.gitconnected.com/doing-a-reverse-proxy-using-apache-to-access-app-trough-http-port-and-avoid-an-ugly-url-1430eb59bd3f

I have also uploaded the docker-compose file that I have been playing with (as a text) file docker-compose.txt

jtumkur commented 3 years ago

Chris and Dave to review this ticket to take the approach

michael-barbour commented 3 years ago

@dmlyons2 Can you verify you've added ProxyPreserveHost On to your /etc/apache/sites-availiable/ file for the chemreg api. This forces apache to pass the entire request to the server, rather than treating the proxy call as it's own web call.

From the gitconnected link @scaduto sent

ProxyPreserveHost on is to pass the original host header to the real web app server (that’s it in localhost:8181).

<VirtualHost *:80>
        ProxyPreserveHost On

        ProxyPass /gin_test1 http://127.0.0.1:8181
        ProxyPassReverse /gin_test1 http://127.0.0.1:8181
</VirtualHost>
jtumkur commented 3 years ago

Further discussion with Dave and Dev team to find further steps.

dmlyons2 commented 3 years ago

This is fixed in staging - was a ProxyPreserve issue. Will update http conf in prod on next push.