Discussion:
localserver using nginx proxy_pass: how can I set the root url to other than localhost
kharis
2018-09-15 03:51:42 UTC
Permalink
I have a django rest app that runs in localhost in a server. It can be
accessed from outside using nginx proxy_pass. It runs fine until I have a
return value from a model that has a FileField. It returns the full url of
the file: localhost:8000/static/a_file.file. It should be my server public
IP address / domain to access the file, something like:
my.domain.com/static/a_file.file. Can I set the base / root url returned
from the model?

Thanks
--
This message and any attachments may contain confidential information and
are intended only for the use of the intended recipient(s). Any disclosure,
distribution or copying of this message and any attachments is strictly
prohibited without approval from PT. Wisanamitra Argakarya. If you are not
the intended recipient, you should notify the sender and delete this
message immediately. PT. Wisanamitra Argakarya is not liable for any damage
caused by any virus or malicious file transmitted by this message. Any
views, opinions, or commitments expressed in this message do not
necessarily reflect the views of PT. Wisanamitra Argakarya.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-09-15 12:22:53 UTC
Permalink
sounds to me you don't have server_name set up for your nginx. But not
sure if this is the relevant place for that, since its not Django/DRF
related, but rather nginx configuration.

Perhaps stackoverflow would be a better place to ask?
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex Daigle
2018-09-15 16:25:54 UTC
Permalink
Remove nginx from the equation. Use runserver because you’re clearly still in development. Does your app work then?

IMHO you are not ready to add more things to your stack yet. The ONLY thing that should be in your stack right now is Django, and possibly a different database because ... sqlite? Never.

Nginx is for the C10k issue, sorry for being blunt but is your app public? do you have 10 users? 100? 10,000? A million? If you said no to any of these, then you shouldn’t be using nginx. Thinking about it? Sure, it’s good to plan your application’s growth. Using it? That’s a hard no.

Shorten your stack.

Alex

PS: Test the URL’s with more verbosity by using ‘curl -v’ or ‘http -v’ (from httpie), in the future for more advanced use cases you can setup a proxy to intercept all requests, pause and examine individual responses.
sounds to me you don't have server_name set up for your nginx. But not sure if this is the relevant place for that, since its not Django/DRF related, but rather nginx configuration.
Perhaps stackoverflow would be a better place to ask?
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-09-16 00:16:06 UTC
Permalink
Post by Alex Daigle
If you said no to any of these, then you shouldn’t be using nginx.
I *strongly* disagree with this. you should use apache with mod_wsg or
nginx with uwsgi/gunicorn/etc for production, in which having 10, 1000 or a
million users is beside the question.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex Daigle
2018-09-16 02:17:39 UTC
Permalink
Jason, we agree. What I mean by having a public app is the same as what you mean by having something in production. Anything in production should have a reverse proxy like nginx or Apache, etc. Reading my message again, I can see why it could have been taken that way when I ranted about the C10k. This (C10k) was an initial goal of the nginx project, not a requirement of its use. I do apologize for that confusion.

Alex
Post by Alex Daigle
If you said no to any of these, then you shouldn’t be using nginx.
I strongly disagree with this. you should use apache with mod_wsg or nginx with uwsgi/gunicorn/etc for production, in which having 10, 1000 or a million users is beside the question.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-09-16 14:51:10 UTC
Permalink
Appreciate the clarification!
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
kharis
2018-09-17 07:48:58 UTC
Permalink
Appologize for the late reply.

So this is related to nginx configuration?
Okay I'll ask in stack overflow then,

My app is public, but used for testing purpose. I'm still learning to
deploy the app.
I use nginx because there's the need to serve react app along with the
django app, i use different port for different app.

Thank you all for the insight!
--
This message and any attachments may contain confidential information and
are intended only for the use of the intended recipient(s). Any disclosure,
distribution or copying of this message and any attachments is strictly
prohibited without approval from PT. Wisanamitra Argakarya. If you are not
the intended recipient, you should notify the sender and delete this
message immediately. PT. Wisanamitra Argakarya is not liable for any damage
caused by any virus or malicious file transmitted by this message. Any
views, opinions, or commitments expressed in this message do not
necessarily reflect the views of PT. Wisanamitra Argakarya.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...