CFChart doesn't - need webserver setup advice - coldfusion

I have a shared hosting account for my ColdFusion websites. One of my customers needs CFChart graphics for his statistics. I've programmed them and they run ok on my own development server, but they don't show up online. The reason is that ColdFusion puts the generated images into /CFIDE which is outside of my part of the file system, and not accessible for me in a shared hosting environment.
IMG SRC="/CFIDE/GraphData.cfm?graphCache=wc50&graphID=Images/4990209100100002.PNG"
The hoster uses IIS on a Windows machine and CF7. He has tried several things (configuration-wise), but so far, nothing helped.
What can we do?

We have a site that creates statistical charts on a schedule. CFChart allows you to store the data to a variable (the "name" attribute). Then use CFFile to write the chart to any location within your webroot. We use it for Flash charts, but I've tested it with PNG as well, and it works fine.

I'm not sure how you'd go about adding this to IIS, but, I've used this on apache to solve the same issue:
Alias /CFIDE /var/www/html/CFIDE
<Directory /var/www/html/CFIDE>
Order deny,allow
Deny from all
</Directory>
<Files ~ "^GraphData.cfm$">
Order allow,deny
Allow from all
</Files>

I believe it would be possible to use the techniques described in this blog post:
link text
And store the image in a location where the browser could get to it.

Related

Django/Apache - read files from network drive (Windows)

I have been working in windows environment for producing & deploying django for internal use at work and been asked to add a feature to read files saved at the network drive (ideally, .xlsx file view). So, I would want to list .xlsx files in a specified folder in the network drive and let the user view the file if clicking on it.
My first approach was to create a user account with "Log on as a service" and "Act as part of the operating system," and run the Apache using this account. But, later realized I can't inherit the access to the network drive my admin account has (or is it possible?).
And, I decided to run it with my admin account, which I know is not a good idea to do in production, but wanted to see that I am on a right track... Tried below config but I am stuck at how to proceed from here to achieve the feature described above.. /l/ is an alias of the UNC of network drive.
<Directory /l/>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
I tried SMB to try connecting but connection error has been returned (not even sure it is applicable in my case). Can anyone please at least guide me whether I am walking in the right direction..?

django 1.6 serving static admin files using alias with apache

So I am converting the Django tutorial to fully work with Apache instead of using the built-in "runserver" command. I got step one working; getting Apache to serve the static files (css). Now I need to get it to serve the static files for the admin.
My code so far in the httpd.conf file for Apache 2.4.
#static files for site
Alias /static/ "C:/mysite/polls/static/"
<Directory "C:/mysite/polls/static">
Require all granted
</Directory>
#static files for admin
Alias /static/ "C:/Python27/Lib/site-packages/django/contrib/admin/static/"
<Directory "C:/Python27/Lib/site-packages/django/contrib/admin/static">
Require all granted
</Directory>
Obviously having the same alias for the 2nd block does not work and the CSS will not load for the admin. The site (1st block) loads fine. Now this page in the Django tutorial details the entire process on how to make it work. I just cannot figure it out. Maybe I am doing a syntax error and I have read countless posts about this both here and elsewhere.
The doc mentions 3 ways to do it. I want to do it the 2nd way; by way of using the alias directive: "Use an Alias directive, as demonstrated above, to alias the appropriate URL (probably STATIC_URL + admin/) to the actual location of the admin files."
Now I don't understand the exact part where it says "STATIC_URL + admin/). I tried various variations of that but it won't work. My link to the admin page is exactly this:
http://127.0.0.1/admin/
Can we figure this out in specific to WINDOWS and DJANGO 1.6? I know prior to DJANGO 1.4 there was a different way using "ADMIN_MEDIA_PREFIX" in the settings.py file. That way is deprecated now and I want to use the alias. And bonus. How do aliases exactly work?
Thanks all.
EDIT:
Link that mentions how to do it. Under "Serving the admin files" I need to figure out the 2nd way using alias.
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/
This is what the "static" app is for. You should do manage.py collectstatic on deployment, and this collects all your static content - both for your apps and for the built-in/contrib ones - into one place, which is where you point your Apache alias to.
But if you really want to hard code it, STATIC_URL + admin just means exactly that: the value of STATIC_URL, suffixed with "admin", so Alias /static/admin.
This is the code that finally works:
Alias /static/admin "C:/Python27/Lib/site-packages/django/contrib/admin/static/admin/"
<Directory "C:/Python27/Lib/site-packages/django/contrib/admin/static/admin">
Require all granted
</Directory>
Alias /static/ "C:/mysite/polls/static/"
<Directory "C:/mysite/polls/static">
Require all granted
</Directory>
Note that ORDER matters greatly. I have to Alias the admin static BEFORE aliasing the site static. Sounds like a cascading type issue and makes sense the more specific gets precedent.
Also I had my link incorrect for the admin. It was ending in ../admin/static/. It should go deeper into ../admin/static/admin/.
Finally 2 areas working to serve static files. The admin comes first and then the site static 2nd.
Thanks to all and this should be really documented and might be a pitfall for some.

cfimage not displaying captcha image

I am using cfimage to generate captcha in coldfusion9. In my project there are three environments named dev, stage and production. The captcha image is getting displayed both in dev and production but in stage it is not displaying the image. When I am looking through firebug the 'src' attribute of the captcha image tag is having the path as, '/CFFileServlet/_cf_captcha/_captcha_img-156564442913310989.png' but the image is not displaying.
Please suggest me what could be the possible cause of this problem.
Thanks
If your server is under Apache, you can also do the mapping directly in your Apache conf file:
Alias /CFFileServlet /opt/coldfusion9/cfusion/tmpCache/CFFileServlet
<Directory /opt/coldfusion9/cfusion/tmpCache/CFFileServlet>
Order allow,deny
Allow from all
</Directory>
Your dev web server not able to find the mapping for the folder 'CFFileServlet'. You can explicitly mention that mapping in the application.cfc file. Like in my case i have created the mapping by
<cfset This.mappings["/CFFileServlet"]="C:\ColdFusion10\cfusion\tmpCache\CFFileServlet">

Django moving from Development server to Deployment Server

Regarding this documentation page from the Django website,
https://docs.djangoproject.com/en/1.2/howto/static-files/
where it says for development "With that said, Django does support static files during development. You can use the django.views.static.serve() view to serve media files."
So my question is, if I use this method, How much work is required to move to apache.
Currently I have a symbolic link to my image folder in the /var/www folder, and in the Django settings I have set the media url to :
MEDIA_URL = 'http://127.0.0.1:80/Images/'
This seems like a fairly easy hack but my project is going to get very big (with lots of css, js and pdfs) and I doubt if this method is good.
My approach was to have apache itself intercept the static files urls and serve them directly without invoking django at all. So my apache config looked something like this:
<VirtualHost *:80>
ServerName www.myproject.com
Alias /static /docs/my_website/static
<Directory /docs/my_website/static>
Order allow,deny
Allow from all
</Directory>
Alias /favicon.ico /docs/my_website/static/images/icons/favicon.ico
Include "/13parsecs/conf/django.conf"
</VirtualHost>
Then you can just keep doing whatever you're doing in the dev environment, and when you get to apache it won't invoke django at all for static content, which is what you want.
This is a perfectly good way of doing things. The only change you'll need to make is to put the actual URL of your site, rather than the localhost IP.
Don't "move to Apache", start using it in the first place. None of the software needed has licensing fees and runs on almost any platform, so the only excuse you could have is "I'm too lazy".

Managing Django static files: with django-static or django-staticfiles?

After doing a bit of googling, I found these projects to help with serving static files:django-static with Nginx, and django-staticfiles.
Is there anybody that has had experience with one, or preferably both of these approaches, and that can recommend one or the other, or a 3rd?
The usual way to handle static files is actually not sending them through django, but let the web server (e.g. apache or ngingx) handle them. I provide a small example for mod_wsgi, based on official django docs, found here.
Alias /media/ /usr/local/wsgi/static/media/
<Directory /usr/local/wsgi/static>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /usr/local/wsgi/scripts/django.wsgi
<Directory /usr/local/wsgi/scripts>
Order allow,deny
Allow from all
</Directory>
The first statement makes sure all files in /media will be served through apache directly, not django. The second statement is for setting up the django site itself. Now, using this media files do not go through django processing, which is often painfully slow.
The reason static file servers exist is mainly for development or very minimalistic rollouts.