I am very new to bitnami/apache/aws and have recently been assigned with figuring out why 3 of our sites are redirecting to one specific site. I have spent countless hours on this and i think i have narrowed it down to the app.conf files. Even when i try to access the /wp-admin or /administrator urls it take me to the other site. Here are two of the app.conf files. Let me know if anything looks out of place. Thanks in advance.
Main site all others are redirecting to
<VirtualHost *:80>
DocumentRoot /opt/bitnami/apps/www.blueleafdef.com/htdocs
ServerName blueleafdef.com
ServerAlias www.blueleafdef.com
ServerAlias blueleafdefr.uat.ignitedev.com
ErrorLog /opt/bitnami/apps/www.blueleafdef.com/log/error.log
CustomLog /opt/bitnami/apps/www.blueleafdef.com/log/access.log common
<Directory "/opt/bitnami/apps/www.blueleafdef.com/htdocs">
Options +Indexes +FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory> </VirtualHost>
One example of other site
<VirtualHost *>
DocumentRoot /opt/bitnami/apps/www.fuelsnews.com/htdocs
ServerName www.fuelsnews.com:80
ServerAlias www.fuelsnews.com
ErrorLog /opt/bitnami/apps/www.fuelsnews.com/log/error.log
CustomLog /opt/bitnami/apps/www.fuelsnews.com/log/access.log common
<Directory "/opt/bitnami/apps/www.fuelsnews.com/htdocs">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory> </VirtualHost>
<VirtualHost *>
DocumentRoot /opt/bitnami/apps/www.fuelsnews.com/htdocs
ServerName fuelsnews.com:80
ServerAlias fuelsnews.com
ErrorLog /opt/bitnami/apps/www.fuelsnews.com/log/error.log
CustomLog /opt/bitnami/apps/www.fuelsnews.com/log/access.log common
<Directory "/opt/bitnami/apps/www.fuelsnews.com/htdocs">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory> </VirtualHost>
<VirtualHost *>
DocumentRoot /opt/bitnami/apps/www.fuelsnews.com/htdocs
ServerName fuelsnewsr.uat.ignitedev.com:80
ServerAlias fuelsnewsr.uat.ignitedev.com
ErrorLog /opt/bitnami/apps/www.fuelsnews.com/log/error.log
CustomLog /opt/bitnami/apps/www.fuelsnews.com/log/access.log common
<Directory "/opt/bitnami/apps/www.fuelsnews.com/htdocs">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory> </VirtualHost>
Use below and restart the apache it will work.
<VirtualHost *>
DocumentRoot /opt/bitnami/apps/www.fuelsnews.com/htdocs
ServerName www.fuelsnews.com
ServerAlias fuelsnews.com
ErrorLog /opt/bitnami/apps/www.fuelsnews.com/log/error.log
CustomLog /opt/bitnami/apps/www.fuelsnews.com/log/access.log common
<Directory "/opt/bitnami/apps/www.fuelsnews.com/htdocs">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory> </VirtualHost>
<VirtualHost *>
DocumentRoot /opt/bitnami/apps/www.fuelsnews.com/htdocs
ServerName fuelsnewsr.uat.ignitedev.com
ServerAlias fuelsnewsr.uat.ignitedev.com
ErrorLog /opt/bitnami/apps/www.fuelsnews.com/log/error.log
CustomLog /opt/bitnami/apps/www.fuelsnews.com/log/access.log common
<Directory "/opt/bitnami/apps/www.fuelsnews.com/htdocs">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory> </VirtualHost>
Related
I want to deploy my django app on a Apache 2.4 server. The same server will host static files. The thing is that this server hosts other php based web sites.
In order for all this to work I just need to install mod_wsgi and configure apache's .conf file related to this web site, is that right?
After reading few articles I came up with this config, assuming that the web site will be in the var/www/ folder :
<VirtualHost *:80>
ServerName example.com
# Alias /events /var/www/events/html
ServerAdmin webmaster#localhost
DocumentRoot /var/www/example
Alias /media/ /var/www/example/media/
Alias /static/ /var/www/example/static/
<Directory /var/www/example/static>
Order deny,allow
Require all granted
</Directory>
<Directory /path/to/example/media>
Order deny,allow
Require all granted
</Directory>
WSGIScriptAlias / /var/www/example/events_promgruz/wsgi.py
WSGIDaemonProcess example.com python-path=/var/www/example:/opt/envs/lib/python3.6/site-packages
WSGIProcessGroup example.com
<Directory /path/to/example/example>
<Files wsgi.py>
Order allow,deny
Require all granted
</Files>
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What would you suggested to change or add to config?
Is there some other steps to ensure that django app will work and that it doesn't interfere other non wsgi apps?
This is what I ended up using:
<VirtualHost *:80>
ServerName expample-domen.com
ServerAdmin webmaster#localhost
Alias /static /var/www/example/static
Alias /media /var/www/example/media
<Directory /var/www/example/static>
Require all granted
</Directory>
<Directory /var/www/example/media>
Order deny,allow
Require all granted
</Directory>
<Directory /var/www/example/example>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess example python-home=/path/to/virtualEnv python-path=/var/www/example
WSGIProcessGroup example
WSGIScriptAlias / /var/www/example/example/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I've setup SSL certification on AWS.
However, this seems to be automatically redirecting to https rather than hitting our vhosts file..
The pages are erroring out with the following...
mixed Content: The page at 'https://preprod-example.co.uk/' was loaded over HTTPS, but requested an insecure stylesheet 'http://preprod-example.co.uk/modules/system/system.base.css?ow428z'. This request has been blocked; the content must be served over HTTPS.
The vhosts file:
<VirtualHost *:80>
DocumentRoot "/var/www/html/example/production"
ServerName preprod-example.co.uk
<Directory /var/www/html/example/production>
order allow,deny
allow from all
AllowOverride all
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/html/example/production"
ServerName preprod-example.co.uk
<Directory /var/www/html/example/production>
order allow,deny
allow from all
AllowOverride all
</Directory>
</VirtualHost>
Where am I going wrong or is this maybe an issue with AWS?
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
you can use SetEnvif just before your 443 virtual host
<VirtualHost *:80>
DocumentRoot "/var/www/html/example/production"
ServerName preprod-example.co.uk
<Directory /var/www/html/example/production>
order allow,deny
allow from all
AllowOverride all
</Directory>
</VirtualHost>
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
<VirtualHost *:443>
DocumentRoot "/var/www/html/example/production"
ServerName preprod-example.co.uk
<Directory /var/www/html/example/production>
order allow,deny
allow from all
AllowOverride all
</Directory>
</VirtualHost>
My site is working on http
I now want it to work using a SSl certificate. I've generated the keys and set up the virtualhost:
<VirtualHost *:80>
WSGIDaemonProcess pms python-path=/home/ubuntu/myapp/myapp:/home/ubuntu/myapp/env/lib/python3.4$
WSGIProcessGroup myapp
WSGIScriptAlias / /home/ubuntu/myapp/myapp/myapp/wsgi.py
<Directory /home/ubuntu/myapp/myapp/myapp>
<Files wsgi.py>
Require all granted
</Files>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerAdmin support#myapp.com
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/ca.crt
SSLCertificateKeyFile /etc/apache2/ssl/ca.key
ServerName leanhotelsystem.com
ServerAlias *.leanhotelsystem.com
DocumentRoot /home/ubuntu/myapp/myapp/myapp
<Directory /home/ubuntu/myapp/myapp/myapp>
<Files wsgi.py>
Require all granted
</Files>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerAdmin support#myapp.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I've also set in wsgi.py:
os.environ['HTTPS'] = "on"
and in settings.py:
WSGI_APPLICATION = 'myapp.wsgi.application'
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
The problem is that when i access the url with https it shows my folder structure, instead of rendering the homepage.
If I access via http it works fine.
Thanks!
Looks like you forget your WSGI settings section in your new VirtualHost.
I am trying to run two different django projects one the same server, with two different domains. Django version is 1.8, and the webserver is Apache 2.4.7.
These are my conf files in sites-available:
#example.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
ServerAdmin admin#example.com
WSGIDaemonProcess example.com python-path=/path/example/WebPortal:/path/example/venv/lib/python3.4/site-packages
WSGIProcessGroup example.com
WSGIPassAuthorization On
WSGIScriptAlias / /path/example/WebPortal/WebPortal/wsgi.py
WSGIApplicationGroup %{GLOBAL}
<Directory /path/example/WebPortal/WebPortal>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /robots.txt /path/example/WebPortal/static/robots.txt
Alias /favicon.ico /path/example/WebPortal/static/favicon.ico
Alias /media/ /path/example/WebPortal/media/
Alias /static/ /path/example/WebPortal/static/
<Directory /path/example/WebPortal/static>
Require all granted
Options -Indexes
</Directory>
<Directory /path/example/WebPortal/media>
Require all granted
Options -Indexes
</Directory>
ErrorLog "/path/example/WebPortal/logs/webportal-error.log"
CustomLog "/path/example/WebPortal/logs/webportal-access.log" combined
CustomLog "/path/example/WebPortal/logs/webportal-bandwidth.log" common
and:
#sub.example2.conf
<VirtualHost *:80>
ServerName sub.example2.com
ServerAlias sub.example2.com
ServerAdmin admin#example2.com
WSGIDaemonProcess sub.example2.com python-path=/path/sub_example2/WebPortal:/path/sub_example2/venv/lib/python3.4/site-packages
WSGIProcessGroup sub.example2.com
WSGIPassAuthorization On
WSGIScriptAlias / /path/sub_example2/WebPortal/WebPortal/wsgi.py
WSGIApplicationGroup %{GLOBAL}
<Directory /path/sub_example2/WebPortal/WebPortal>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /robots.txt /path/sub_example2/WebPortal/static/robots.txt
Alias /favicon.ico /path/sub_example2/WebPortal/static/favicon.ico
Alias /media/ /path/sub_example2/WebPortal/media/
Alias /static/ /path/sub_example2/WebPortal/static/
<Directory /path/sub_example2/WebPortal/static>
Require all granted
Options -Indexes
</Directory>
<Directory /path/sub_example2/WebPortal/media>
Require all granted
Options -Indexes
</Directory>
ErrorLog "/path/sub_example2/WebPortal/logs/webportal-error.log"
CustomLog "/path/sub_example2/WebPortal/logs/webportal-access.log" combined
CustomLog "/path/sub_example2/WebPortal/logs/webportal-bandwidth.log" common
With this configuration when I enable both, only one domain work properly...on the other one I get a Bad Request (400).
I have tried many options but no one work.
Any ideas?
I have an app that functions properly on my local wamp server using the virtual host configuration seen below. I recently purchased shared hosting, but unlike my localhost, I dont have access to Apache's httpd-vhost.conf and instead must manipulate the site root's .htaccess file in order to "wire up" my application properly.
The problem is that I do not know how to use the RewriteEngine to write RewriteRules that can emulate (to some degree) this virtual host config:
<VirtualHost *:80>
ServerName sitename
ServerAdmin webmaster#localhost
DocumentRoot "c:/wamp/www/siteroot"
AliasMatch /(.*)\.(js|css|rdf|xml|ico|txt|gif|html|png|jpg|jpeg|json|eot|woff|svg|ttf|pdf)$ "c:/wamp/www/siteroot/app/$1.$2"
AliasMatch /rest/(.*) "c:/wamp/www/siteroot/rest/$1"
AliasMatch /img/(.*) "c:/wamp/www/siteroot/app/img/$1"
AliasMatch /(.*) "c:/wamp/www/siteroot/app/index.php"
ErrorLog "logs/sitename_app_error.log"
LogLevel warn
CustomLog "logs/sitename_app_access.log combined" %a
</VirtualHost>
<VirtualHost *:80>
ServerName admin.sitename
ServerAdmin webmaster#localhost
DocumentRoot "c:/wamp/www/siteroot"
AliasMatch /app/(.*)\.(js|css|rdf|xml|ico|txt|gif|html|png|jpg|jpeg|json|eot|woff|svg|ttf|pdf)$ "c:/wamp/www/siteroot/app/$1.$2"
AliasMatch /i18n/(.*)\.json$ "/wamp/www/siteroot/app/i18n/$1.json"
AliasMatch /(.*)\.(js|css|rdf|xml|ico|txt|gif|html|png|jpg|jpeg|json|eot|woff|svg|ttf|pdf|csv)$ "c:/wamp/www/siteroot/adminApp/$1.$2"
AliasMatch /rest/(.*) "c:/wamp/www/siteroot/rest/$1"
AliasMatch /img/(.*) "c:/wamp/www/siteroot/adminApp/img/$1"
AliasMatch /(.*) "c:/wamp/www/siteroot/adminApp/index.html"
ErrorLog "logs/sitename_app_error.log"
LogLevel warn
CustomLog "logs/sitename_app_access.log combined" %a
</VirtualHost>
<Directory "c:/wamp/www/siteroot">
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "c:/wamp/www/siteroot/app">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
<Directory "c:/wamp/www/siteroot/adminApp">
AuthName "Login required"
AuthType Basic
AuthUserFile "c:/wamp/www/siteroot/adminApp/.htpasswd"
AuthGroupFile "/dev/null"
Require valid-user
</Directory>
<Directory "c:/wamp/www/siteroot/rest">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
*note that sitename and siteroot aren't the actual names of the site/filepath.
The aliasMatches are what's most important for my site to "work." This is why I think I can get by using the RewriteRules in .htaccess.
Even if you aren't familiar with RewriteRules, if you could tell me what the regular expressions mean, that would be of great help too! Any assistance is appreciated!