Title: Absolute URLs without port · Issue #66 · realpython/dockerizing-django · GitHub
Open Graph Title: Absolute URLs without port · Issue #66 · realpython/dockerizing-django
X Title: Absolute URLs without port · Issue #66 · realpython/dockerizing-django
Description: So I used this to build a dockerized API with Django Rest Framework. Since I develop several projects at once, I use a different port for local development. Turns out that Django or at least Django Rest Framework was not able to produce ...
Open Graph Description: So I used this to build a dockerized API with Django Rest Framework. Since I develop several projects at once, I use a different port for local development. Turns out that Django or at least Django...
X Description: So I used this to build a dockerized API with Django Rest Framework. Since I develop several projects at once, I use a different port for local development. Turns out that Django or at least Django...
Opengraph URL: https://github.com/realpython/dockerizing-django/issues/66
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Absolute URLs without port","articleBody":"So I used this to build a dockerized API with Django Rest Framework. Since I develop several projects at once, I use a different port for local development. Turns out that Django or at least Django Rest Framework was not able to produce the right absolute URLs in the browsable API. Instead of `localhost:12345/api`, I only got `localhost/api`.\r\n\r\nWhat I tried:\r\n- setting `USE_X_FORWARDED_FOR_HOST` and `USE_X_FORWARDED_FOR_PORT` to True, see https://docs.djangoproject.com/en/3.0/ref/settings/#use-x-forwarded-host\r\n\r\nAnyway, what fixed it for me was using `$http_host` instead of `$host` in the nginx config.\r\n```\r\nserver {\r\n listen 80;\r\n # server_name localhost;\r\n charset utf-8;\r\n\r\n location /static {\r\n alias /usr/share/nginx/static;\r\n }\r\n\r\n location / {\r\n proxy_pass http://web:8000;\r\n proxy_set_header Host $http_host; # $host is without port, $http_host works\r\n proxy_set_header X-Real-IP $remote_addr;\r\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n }\r\n\r\n}\r\n```\r\n\r\nMy issue: https://github.com/lorey/socials-api/issues/4\r\nMy configuration: https://github.com/lorey/socials-api/tree/d7f0bca4df5be9c662ede96aac6ae89d17890404\r\n\r\nHope this helps anyone. Let me know if someone finds a better solution or can explain this.","author":{"url":"https://github.com/lorey","@type":"Person","name":"lorey"},"datePublished":"2020-05-06T10:22:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/66/dockerizing-django/issues/66"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ba554c7c-b20f-8318-62da-080a5bbea9c2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA6E:1EF752:173006B:20AAD37:697B90EF |
| html-safe-nonce | 14d0cc8d4e21d28fa2716f2751b90c5aac1fbc7f59a65c69008035f2c3d5c46f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTZFOjFFRjc1MjoxNzMwMDZCOjIwQUFEMzc6Njk3QjkwRUYiLCJ2aXNpdG9yX2lkIjoiMzUwMzA4OTAwMzI4NjcyODk0MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9fd488daf159216d49355e3fc1cba67c34bd019db46738b196f2ee125228cbbb |
| hovercard-subject-tag | issue:613210334 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/realpython/dockerizing-django/66/issue_layout |
| twitter:image | https://opengraph.githubassets.com/77103599e18573d690d3624acd600c936502d427bb71f420d3fc56c768588af4/realpython/dockerizing-django/issues/66 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/77103599e18573d690d3624acd600c936502d427bb71f420d3fc56c768588af4/realpython/dockerizing-django/issues/66 |
| og:image:alt | So I used this to build a dockerized API with Django Rest Framework. Since I develop several projects at once, I use a different port for local development. Turns out that Django or at least Django... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lorey |
| hostname | github.com |
| expected-hostname | github.com |
| None | 86b3730167656228ed8d24c4f0770806131d1f695bff36b9485630bb7443aa64 |
| turbo-cache-control | no-preview |
| go-import | github.com/realpython/dockerizing-django git https://github.com/realpython/dockerizing-django.git |
| octolytics-dimension-user_id | 5448020 |
| octolytics-dimension-user_login | realpython |
| octolytics-dimension-repository_id | 35793912 |
| octolytics-dimension-repository_nwo | realpython/dockerizing-django |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 35793912 |
| octolytics-dimension-repository_network_root_nwo | realpython/dockerizing-django |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6adfecb5bc9d8f1aac645d1f3797aca9d302dd85 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width