I'm using a virtual dedicated server which allow not to change apache virtual hosts. So I'm stuck with only one wsgi file.
There is few doc about multisite in django, so I believe the answer to my question is NO, but I prefere to be sure : is there any way to declare more than one website inside a wsgi file ? Or must I use some middleware ?
If you cannot change the VirtualHost at all then you may not get very far. You at least need to be able to add additional ServerAlias directives to the VirtualHost such that the extra hostnames get mapped to that WSGI application. If they are all a sub domain then a wildcard can be used, but you still need to be able to add the wildcard ServerAlias for sub domains to the VirtualHost.
Related
Problem:
I have a number of subdomains like foo.website.com, bar.website.com and so on.
One of them is the resources.website.com and the resources from it need to be available for all other ***.website.com subdomains.
Obviously, the browser with foo.website.com (with a .js resource from resources.website.com) is running into CORS problem.
Working code:
I am trying to configure my .htaccess of the resources.website.com to determine whether the request is performed from ***.website.com and the following solution works perfectly fine
<FilesMatch "\.(js|css|ttf|otf|eot|woff|ico)$">
SetEnvIf Origin "http(s)?://(.*\.website\.com)$" AllowOrigin=*
Header add Access-Control-Allow-Origin %{AllowOrigin}e env=AllowOrigin
</FilesMatch>
What I would like to do:
Id like to be able to keep the .com (the zone) outside of the .htaccess in the apache configuration files. (I have multiple environments under different zones so when the code, including the htaccess files, gets deployed on other zones, it is totally neutral).
In apache configuration files I have
SetEnv domain_zone com
.. and I would like to use this variable in the code above`s regexp (if its possible) like:
SetEnvIf Origin "http(s)?://(.*\.website\.%{domain_zone}e)$" AllowOrigin=*
.. but I obviously lack .htaccess skills. Thank you.
I have Mod rewrite set to pick up people who come to the root of my domain and redirect them to the proper language folder in my Django
Im running a new Django with mod_wsgi under apache. I have an apache instance with a virtual server set to port 8005 and my load balancer pointed to that server and port.
I have only one rule in Mod Rewrite to redirect to US folder
RewriteRule ^(|/|/index.html)$ /us/ [QSA,NE,R=302,L]
When I try to go to my www.site.com I see in my trace logs its trying to redirect to www.site.com:8005/us/ instead it should go to www.site.com/us/
If I go to www.site.com/us/ works fine
In the apache configs i needed add servername hostname I had a different hostname that was preventing it from redirecting properly. I haven esperienced this problem on my non Django sites
I have hosted to django admin project on a local machine X.
http://10.4.x.y/myapp/admin works.
I have an external IP on another machine Y and i am doing a proxy pass
from the Y to X.
http://proxypassname.com/myapp/admin works.
But, When i click the link "Save" or "Save continue editing" button after editing in admin page, it redirects to local machine ip (i.e. http://10.4.x.y/myapp/blah_blah_blah).
How to make sure that the django project redirects to proxypass name instead of local IP?
This is happening because the admin redirects to IP it thinks it has. It gets in in the HTTP request's header.
However, the fix is very easy. Assuming you proxy server implements the X-Forwarded-For standard, it could be easily fixed.
in your settings.py, simply set:
USE_X_FORWARDED_HOST = True
and restart your Django.
If that doesn't work, you can try to see if your proxy sets a different kind of header, and write a middleware that does the same thing. It's the first example on Django's documentation chapter on middleware
I did these two things and it worked.
Whenever you add a ProxyPass, you should add ProxyPassReverse
SITE_ID should be set to the domain where you want to point this django project.
I have a django web application that's running on apache 2.2.14 and I want to run the admin application over https.
Having read considerable discussions on using a proxy, writing middleware, running alternative wsgi scripts, the chaps in #httpd came to my rescue. The solution is so simple, I was surprised I didn't find it online, so I'm curious to see if I've made some glaring assumptions or errors.
One complication was that I also wanted to run one of my django apps in the site over https, that is everything on /checkout.
Essentially, if a user requests a URI starting with /admin or /checkout on http, they are to be redirected to that URI but on https. Conversely, if a user requests a URI that does not start with /admin or /checkout on https, they are to be redirected to that URI but on http.
The key to solving this problem was to use Redirect and RedirectMatch directives in my VirtualHost configuration.
<VirtualHost *:80>
... host config stuff ...
Redirect /admin https://www.mywebsite.com/admin
Redirect /checkout https://www.mywebsite.com/checkout
</VirtualHost>
<VirtualHost *:443>
... ssl host config stuff ...
RedirectMatch ^(/(?!admin|checkout).*) http://www.mywebsite.com$1
</VirtualHost>
Another approach is to use #secure_required decorator. This will automatically rewrite the requested url and redirect to https://... version of the URL. Then you don't have to have Redirect in *:80 configuration. *:443 configuration may still be required for performance purpose if you want other traffic to go through normal http traffic.
I tried your solution, but ran into several problems. First, the formatting on the admin site disappeared, as if it could not find the admin static files. Second, if I tried to reach the non-admin site through https, the browser would not find it and redirect me to Yahoo search. Oddly, if I edited the yahoo search URL to eliminate all text except my correct URL (minus the http://), it would continue to search through yahoo for my site. However, typing the exact same URL afresh sent me to my site.
I solved all of these issues by simply removing the
RedirectMatch ^(/(?!admin|checkout).*) http://www.mywebsite.com$1
directive.
I should mention that I don't have a /checkout section on my site and am only trying to secure /admin. ... and yes, I did substitute my URL for "mywebsite.com"
What you described should work, but there may be a problem in the future if you need to make changes to which paths are/are not HTTPS. Because this method requires the ability to correctly modify the Apache config file it means you do not want novices in the loop. Screw up the config file and your site can go 500-error in the blink of an eye.
We chose to have a simple text file that had a list of the must-be-HTTPS paths. Anyone on the project can edit it and it is checked for correctness when it is loaded. We handle any needed redirects to/from HTTPS in middleware and it seems to work just fine. This method will also work if you are running anything other than Apache.
Note: where you will see "xttp" actualy is "http" but stackoverflow rules do not allow me to use more than 1 hyperlink in one post because I do not have enough "credit" to do that :)
INTRODUCTION
Hi,
I have installed a MediaWiki 1.15.3 software on a private LAN on a Linux box (CentOS 5), with: Apache 2.2.3, PHP 5.1.6, MySQL 5.0.45. Let's name this Linux box "wiki box".
Public users can't access this wiki as it is hosted on a private LAN.
For external users (the Internet users) we have a Linux router (with Apache 2.0.52) where we host our website (ex: xttp://www.cubique.ro). Let's name this Linux box "router".
WHAT I WANT
What I want to do is:
to create a virtual domain (as xttp://wiki.cubique.ro) on the "router"
setup the virtual domain to forward all xttp requests to my private "wiki box" (ex: xttp://192.168.0.200/wiki_root/)
WHAT I'VE DONE ALREADY
On router's Apache (httpd.conf) I have created a VirtualHost as:
< VirtualHost 0.0.0.0:80 >
ServerName wiki.cubique.ro
DocumentRoot /someinternalpath/html
ScriptAlias /cgi-bin /someinternalpath/cgi-bin
...
Well, after I have navigate at wiki.cubique.ro I saw a blank web page, as /someinternalpath/html has an empty index.htm page.
No problem, I know that I have to "teach" the router to pass all the access of virtual domain (wiki.cubique.ro) to the wiki box, where the real pages are stored.
So I teach the Apache to ProxyPass the access of virtual domain root to the wiki box root like this:
...the following lines lies in the same virtual domain definition, see above
ProxyPass / xttp://192.168.0.200/wiki/
ProxyPassReverse / xttp://192.168.0.200/wiki/
< /VirtualHost >
WHAT IS THE ISSUE
If I access the wiki using the internal address (such as xttp://192.168.0.200/wiki/) it looks splendid (style sheets, everything).
When I access the wiki using the virtual domain name ( xttp://wiki.cubique.ro ) it shows the content but no style sheet. Worse than that, no internal wiki links are working at all.
Make a try: http://wiki.cubique.ro
FINALLY, THE QUESTION
Anyone has a clue how to deal with this?
Thanks.
You should check your path variables in LocalSettings.php, especailly $wgStylePath and $wgServer