I am using Django as web framework and then Apache and Lighttpd as web server and static media server respectively. Lighty serves all my static content well and good, but I need to configure it to serve the new files uploaded by the user. Lighttpd is running on a different machine from the Apache(Django) one. My django code of creating a directory and then creating an image file gets executed on my Apache machine, making it currently getting saved in the same machine itself. I want this directory and file creation happen on my static media server, which should then be served by the media server itself. I am using os.mkdir and urllib.urlretrieve functions respectively to create directory and save files on the Django(Apache) machine. Is there anyway that I can do some configuration tweaking to get these things work or I need to write scripts on the media server and call em from Django machine??
help needed with Lighttpd and Apache cofiguration with Django
550 views Asked by Bharath AtThere are 2 answers
Peter Rowell
On
This is the kind of stuff I use rsync for. Do whatever you like on the main server and then periodically (or on demand) rsync push to the static server. Rsync is faster (and more featureful) than anything you can produce with a quick hack.
Just because I'm paranoid I do hourly rsync's of all my customer sites to 2 backup servers, one of which is in my garage. I just timed an "rsync -a" against a 1.7GB customer site (which didn't have any changes) and it took 9.92 seconds wall-clock-time, including the 3 network handshakes for rsyncing 3 different directories. Had anything changed, presto-bango, it's done, complete with timestamps, owner/group, etc.
It's amazing how blasé you can become about server failure when you get true, multi-machine, no-humans-involved backup working. I sleep real good.
Related Questions in DJANGO
- Django Admin Panel and Sub URLs Returning 404 Error on Deployment
- How to return HTTP Get request response from models class in Django project
- Issue with Quantity Increment in Django E-commerce Cart
- Can't install Pipenv on Windows
- use dict from python in django html template and also in js
- 'pyodbc.Cursor' object has no attribute 'callproc', mssql with django
- Django socketio process
- Root path analogue in uWSGI as in Uvicorn
- Django - ModuleNotFoundError: No module named 'backend'
- Does Python being a loosely typed programming language make it less secure?
- sorl-thumbnail adds a background color when padding is used
- Can't connect to local postgresql server from my docker container
- Why ProductHunt api dont work with Python?
- why i have to put extra space in before write option selected because it show error if i don't ' option:selected'
- Django Arrayfield migration to cloud sql (Postgresql) not creating the column
Related Questions in APACHE
- Special access rule in an .htaccess file for IP addresses, authorized only for one directory structure
- How to isolate PHP apps from each other on a local machine(Windows or Linux)?
- Cannot load modules/mod_dav_svn.so into server
- How to ignore case in regexp mapping in a .htaccess rewrite rule?
- Oracle Http server ISNT-07551
- I cant access file directory with PHP local host on XAMPP. it just shows one of the files I have in my visual studio code
- Apache Reverse Proxy: only one proxy directive is working. Second one is ignored
- Issue with Django --> Apache WSGI deployment
- changing the node version used by apache web server
- Apache: How can I redirect to a subfolder with a URL param but serve required content via the main URL?
- Why/How does Apache auto-include "DHE" TLS1.2 ciphers while nginx needs "dhparams" file?
- Set up MX records in apache/Ubuntu to point to external mail server
- How to proxy to another port?
- Php can not upload file out of /var/www/html even after disabling Selinux
- Serve static site on S3 + CloudFlare with Apache retaining the source URL
Related Questions in LIGHTTPD
- Environment variable PATH_INFO not defined by lighttpd using uwsgi module
- How can I customize the web page displayed when a user is prompted for username and password via the browser basic/digest authentication modal?
- Problem with `git instaweb` on OpenSUSE Tumbleweed: No such projects found
- lighttpd return 403 for python script that had been working on older installs
- Lighttpd + webpy + venv: how to configure
- Lighttpd: how to rewrite the URI before passing to uwsgi?
- Getting errors on new lighttpd installation gw_backend.c.324) child exited: 0 unix:/var/run/lighttpd/php.socket-0
- Track down PHP crash running in lighttpd - no logs
- why http is not working on 80 port for lightpd?
- Weird User Request in access log
- Home Assistant reverse proxy through Lighttpd - (HTTP 400) Unexpected char in url schema
- Redirect specific url to static page using lighttpd
- How to proxy websocket and http over lighttpd to different ports?
- How to deploy flask app on lighttpd server on yocto linux using flup , fastCGI package for production
- Installing a custom lighttpd.conf in Yocto
Related Questions in LIGHTY
- Lighty netconf implementation using spring boot application
- Execute gphoto2 on lighty/lighttpd on raspbian
- Lighttpd with an second document-root
- Web application design that is independent of servlets (uses Web server no application server )
- Can't access to socket.io.js on Raspberry Pi with Lighttpd [Node.JS & Socket.IO]
- Streaming webm video using lighttpd memory usage
- Lighttpd's mod_rewrite module
- Not using fork calls in LIGHTTPD source
- Opencart 1.4.9.4 redirects on Lighttpd 1.4.19-5+lenny2
- Apache RewriteCond to Lighttpd
- Rails Deployment on Win32 Best Practices: Lighty + Sgci
- help needed with Lighttpd and Apache cofiguration with Django
Related Questions in STATIC-MEDIA
- Serve static files with Django without STATIC_URL
- Symfony2 Define Media Uploaded Directory in Config file and access it it in controller twig
- Changing default url to static-media in Flask
- Speeding up site using gzip and far-future expiration dates
- Serving static media during Django development: Why not MEDIA_ROOT?
- help needed with Lighttpd and Apache cofiguration with Django
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The simplest answer is that the user uploads to a shared directory that both web servers can access. Then it is available instantly. If you are using unix (sounds like it) then NFS is a possible solution. If you think your site will scale to multiple servers a la flickr then using rsync to push to multiple edge servers and possibly even implementing a sharding scheme is another solution.
Just be careful. There are a lot of security concerns that depending on your app you have to consider.
If all files go to a publicly accessible directory it could be possible for users to guess the names of other peoples files and download them. In that case you'll want to serve them from Django with a thin layer of security on top.
Never trust your users! Verify that what they upload is in a certain allowable set. Under no circumstances should you allow them to upload whatever they want to. Unless of course your users are a trusted few. Even then you should do some checks. They probably shouldn't be uploading .php files for one. The last thing you want to give them is the ability to run arbitrary scripts on your server. At least configure the directory to just serve up files and not execute anything.
Good luck