I'm trying to make my own custom CDN to make my website and my clients websites load more quickly.
I thought of doing something like this:
The user uploads the files they want on the CDN to a /cdn folder in their hosting account.
The files aren't uploaded to the CDN straight away
The files are only uploaded when the file is requested using the CDN
So my question is, how can I cause a script to run during the HTTP request to allow the CDN to go and grab the file?
Can I do something like this using Apache? I'm using Apache web servers.
It seems to me that what you are trying to do is essentially have servers load files from one primary server. I would recommend not running a script but using the CDN servers as proxies which cache the responses.
You would have to setup something like this in your apache (virtual)host directive.
ProxyRequests off
ProxyPass / http://backend.example.com/
ProxyPassReverse / http://backend.example.com/
CacheRoot /var/cache/apache/
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1
See these entries:
mod_cache
mod_proxy
htcacheclean
Hope that helps!
Related
I'm starting from the bitnami jenkins stack. Everything is working perfectly with jenkins.
http://sample:8080/jenkins (works fine)
I'm trying to add additional directories to apache to proxy to nginx:
http://sample:8080/other_tool
I can get to the other_tool homepage, but references to that other tool break down because they are looking for http://sample:8080/relative_url rather than http://sample:8080/other_tool/relative_url
I can pull config settings from the necessary files as needed, but it is on an air-gapped network so wholesale posting would be a challenge
The apache conf looks like:
<Directory /other_tool>
ProxyPass http://localhost:9999
ProxyPassReverse http://localhost:9999
</Directory>
The nginx configuration is a standard "/" with root directory. I'm not as familiar with nginx so I can't recall the exact information off the top of my head. If needed I will provide it.
I could try to switch the jenkins hosting over to nginx, but I'm not sure that simplifies anything.
I can't open more ports on the machine. I can't use a subdomain as that would require additional DNS entries that I do not control.
Ideas or suggestions?
I am running a Wicket web application in Apache Tomcat on two separate servers. When the application runs on server #1, all of the images are delivered without errors or warnings on both http: and https:, so I don't think there is a problem with the html file. When I run the same application on server #2, all of the images are delivered over http:, but some of the images are giving 404 Not Found when delivered over https:.
For example:
/path/image1.png and is delivered successfully over http and https.
/path/some/sub/directory/image2.png is delivered over http, but not delivered over https.
More specifically, if I request https://domain/path/some/sub/directory/image2.png, I get a 404 error. But if I specify the port and request https://domain:8443/path/some/sub/directory/image2.png the image is delivered.
As the images both work on the first server, I suspect there is some problem with my Apache configuration on the second server. I can't find any directives specific to the functioning or malfunctioning directories in the apache2.conf, httpd.conf, or .htaccess files.
Where should I look to find the directive that allows image1 to be delivered successfully so that I can copy the rules for image 2?
:::EDIT:::
I found the following directives in extras/httpd-ssl.conf. We are using varnish to cache static content.
# Terminate SSL here and pass everything to Varnish
RequestHeader set X-Forwarded-Proto "https"
ProxyPreserveHost on
ProxyPass / http://128.138.128.89:80/
ProxyPassReverse / http://128.138.128.89:80/
This is running on Linux Mint on Oracle VirtualBox if that matters.
I am using JBoss/Tomcat + Mysql cartridges.
I would like to serve static resources (css,js,images) using Apache and host those files outside the WAR.
I would also like to be able to use Apache to configure redirect rules etc. Is there a way to do that? Thanks
You can not edit the vhost for your application, nor access the apache configs for your application when using one of the java cartridges. An apache proxy sits in front of your application, but is not accessible by you. You would either need to run a second gear with the php cartridge and host your static assets there, or try using a third party CDN to host your static files (such as amazon s3 or cloudfront). But with just using one of the java cartridges on OpenShift Online, you can not configure it the way that you are trying to.
You can do this as below. Put images, js & Css folder in Virtualhost document root. And call tomcat with help of mod_proxy_ajp configuration listed below.
ProxyPass /images !
ProxyPass /js !
ProxyPass /css !
ProxyPass / ajp://localhost:9009/
ProxyPassReverse / ajp://localhost:9009/
I'm using apache httpd v2.2 server as a frontend proxy for our actual tomcat web server which hosts the Java web application.
I want to forward all urls received by apache webserver other than those having the prefix /product to tomcat.
I've tried the following set up in httpd.conf but it' doesn't seem to work
<VirtualHost *:6111>
ServerName localhost
RewriteEngine on
RewriteRule !^(/product($|/)) http://localhost:1234/$1
Alias /product /opt/productdoc
</VirtualHost>
I tried to follow Redirect site with .htaccess but exclude one folder but was not successful
Basically all http://localhost:6111/product urls should serve from hard drive (using alias)
Any other url should be forwarded to http://localhost:1234/<original-path>
You probably want to use something like mod_jk http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html.
There are a ton of examples and tutorials and it should be pretty simple to setup and install. Now that you know the name of the connection technology, you should probably be able to find more information.
Using modjk also allows you to secure your tomcat server and keep the public off of it.
This is an outside shot I know. I am supporting a site that has constantly changing assets that are excluded from the repository for obvious reasons. Currently I am having to FTP these assets to my local computer in order to develop and test properly. What I want to do is simply link to the assets on the server. I thought this might be possible using Apache's mod_alias, but I cant get it to work:
Alias /assets http://www.mysite.com/assets
Is this possible? Is there an alternative way of doing this?
Thanks
You can use mod_proxy to make Apache fetch resources from a remote server and then return them under that URL:
ProxyRequests Off
ProxyPass /assets http://www.mysite.com/assets
ProxyPassReverse /assets http://www.mysite.com/assets
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html