i have apache2.conf
<VirtualHost 91.218.230.130:8080>
ServerName dopisaka.ru
DocumentRoot /var/www/dopisalki.ru/data/www/dopisaka.ru
SuexecUserGroup dopisalki.ru dopisalki.ru
CustomLog /var/www/httpd-logs/dopisaka.ru.access.log combined
ErrorLog /var/www/httpd-logs/dopisaka.ru.error.log
ServerAlias www.dopisaka.ru
ServerAdmin 911#dopisalki.ru
AddDefaultCharset utf-8
<Directory "/var/www/dopisalki.ru/data/www/dopisaka.ru">
Order allow,deny
Allow from all
</Directory>
Alias /manager/ "/var/www/dopisalki.ru/data/www/dopisaka.ru/manager/"
ScriptAlias /cgi-bin/ /var/www/dopisalki.ru/data/www/dopisaka.ru/cgi-bin/
WSGIScriptAlias / /var/www/dopisalki.ru/data/www/dopisaka.ru/django.wsgi
</VirtualHost>
but http://www.dopisaka.ru/ show just a "Index of".
whats wrong?
You have included an IP address in the VirtualHost directive. Did you provide a compatible NameVirtualHost directive using that IP address along with the port? If you didn't then likely that the VirtualHost configuration isn't being used at all, and instead the default virtual host definition is being used and it is that which is set up to return the index. More often that not using an IP address in VirtualHost is not what you want to do and you should just use '*:8080', still remembering though that you need a matching NameVirtualHost directive.
Try to remove the DocumentRoot directive. Also your wsgi script seem to be under DocumentRoot, you don't want the script under DocumentRoot because that make it readable by everyone.
Related
I have successfully installed SSL certificate with certbot and lets encrypt on my debian and apache linux virtual machine on google cloud.
the domain is successfully secure with HTTPS.
Although on directly accessing the external ip address i am still getting an unsecure version of the website.
How to redirect the ip directly to the HTTPS version set up with APACHE and just the "domain.com" towards -->> HTTPs:www.domain.com .
I have tried to re-route to port 80 and 443 towards the HTTPS version as in PHP without any luck as shown here :
How to redirect from www to https www with htacces?
in my 000-default.conf:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster#localhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.bracketline.com [OR]
RewriteCond %{SERVER_NAME} =localhost
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI}
[END,NE,R=permanent]
</VirtualHost>
and on my 000-default-le-ssl.conf i have:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName localhost
ServerAdmin webmaster#localhost
Alias /static /var/www/static-root
<Directory /var/www/static-root>
Require all granted
</Directory>
Alias /media /var/www/media-root
<Directory /var/www/media-root>
Require all granted
</Directory>
<Directory /var/www/venv/src/cfehome>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess cfehome python-
path=/var/www/venv/src/:/var/www/venv/lib/python3.5/site-packages
WSGIProcessGroup cfehome
WSGIScriptAlias / /var/www/venv/src/cfehome/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerAlias www.bracketline.com
SSLCertificateFile
/etc/letsencrypt/live/www.bracketline.com/fullchain.pem
SSLCertificateKeyFile
/etc/letsencrypt/live/www.bracketline.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
I am not sure how this thing works if a detailed blog or turorial could be given it would be of great help. thanx in advance!
First lacate which .conf file youre actually using by typing apachectl -S (this works on Debian based OS'es).
Next up edit the file, it should look simillar:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
Protocols h2 http/1.1
# SSL Configuration
# Other Apache Configuration
</VirtualHost>
In general there are several tutorials how to configure HTTP to HTTPS redirect:
Redirect HTTP to HTTPS in Apache
How to Redirect HTTP to HTTPS on Apache
Apache Redirect to HTTPS
And some interesting discusson Why is my Apache VirtualHost directing to the wrong VirtualHost?
Lastly - here's another SO discussion on that topic that has an accepted answer.
Those are just recent (up to 2 years old) examples that will help you and there are dozens more if they won't answer your questions.
Haven't used WAMP in years, but decided to try it again today for a project I am going to work on. I have everything setup and working, but for some reason the error log locations I am defining in my virtual host file are not working - all log entries still go to the default files at c:\wamp64\logs\ rather than the custom ones I specified below.
My vhost file is :
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName site.local
ServerAlias site.local
DocumentRoot "C:/Users/Support/Documents/My Web Sites/BS4/site.com"
<Directory "C:/Users/Support/Documents/My Web Sites/BS4/site.com">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
ErrorLog "logs/site.local-error.log"
CustomLog "logs/site.local-access.log" common
</VirtualHost>
Am I missing something here? I want to have different logs for each 'project' I am working on (only one defined for now), but having them separate makes more sense.
Change your definition of the log files to include the full path.
You might also like to add a seperate log file for the PHP error log.
ErrorLog "C:/wamp/logs/localhost-error.log"
CustomLog "C:/wamp/logs/localhost-access.log" common
php_value error_log "C:/wamp/logs/localhost.php.error.log"
and
ErrorLog "C:/wamp/logs/site.local-error.log"
CustomLog "C:/wamp/logs/site.local-access.log" common
php_value error_log "C:/wamp/logs/site.php.error.log"
So I may be missing a bit of a fundamental understanding on what's going on here, but I cannot get this to work. I have two django websites, and I want to be able to host them both on the same box, both on port 80. Is there some magic to get this to work properly? Here's what my sites-available/default file looks like:
<VirtualHost *:80>
WSGIScriptAlias / /path/to/proj/apache/django.wsgi
AliasMatch ^/([^/]*\.css) /path/to/proj/static/
Alias /media /path/to/proj/static/
Alias /static/ /path/to/proj/static/
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi
ErrorLog ${APACHE_LOG_DIR}/error2.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Obviously this doesn't work since navigating to the site hits the first one and it never goes to the second one. So my question is, how do I set this up so I can host 2 web sites on port 80. Perhaps I could do like localhost/site1 and localhost/site2 and figure it out that way, but no matter what I try I can't seem to get that to work.
I have played with the ServerName property, but I don't really understand how that can work, setting it doesn't seem to change that hitting the ip of that machine only shows the first website, and I don't know where using the ServerName affects anything.
Any suggestions, or let me know if I need to give more information.
Also note they both work if I change the second one to port 8080, but when doing that I can't seem to put a domain name on top of myip:8080.
I don't think there is anything to explain here. You just need to actually specify the name of each virtual domain.
Note:NameVirtualHost is deprecated
<VirtualHost *:80>
ServerName site1.ltd
WSGIScriptAlias / /path/to/proj/apache/django.wsgi
AliasMatch ^/([^/]*\.css) /path/to/proj/static/
Alias /media /path/to/proj/static/
Alias /static/ /path/to/proj/static/
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName site2.ltd
WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi
ErrorLog ${APACHE_LOG_DIR}/error2.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I followed the django docs on how to deploy django 1.4 to apache using mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ on mac osx lion and when I add the WSGIPythonPath directive apache cant restart .Yet without it my app is non existant in the path . In the log I am getting an error that reads
WSGIPythonPath cannot occur within VirtualHost section
here is what my virtual host config looks like
<VirtualHost *:80>
ServerAdmin jmured#gmail.com
DocumentRoot "/Users/jamo/code/work/projects/bfpd/fapp"
ServerName bfpd.dev
ServerAlias bfpd.dev
ErrorLog "/private/var/log/apache2/bfpd.dev-error_log"
CustomLog "/private/var/log/apache2/bfpd.dev-access_log" common
Alias /static/ /Users/jamo/code/work/projects/bfpd/fapp/fapp/static/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp/static>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
IndexOptions FancyIndexing
</Directory>
WSGIScriptAlias / /Users/jamo/code/work/projects/bfpd/fapp/fapp/wsgi.py
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
what am i doing wrong ???
I fixed it.
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
should be in http.conf
As mentioned in the comment by nemesisfixx, and specified by the error in your original question:
WSGIPythonPath cannot occur within VirtualHost section
Moving WSGIPythonPath outside of VirtualHost resolved Apache crashing on OS X server.
$ cat sites/0000_any_80_mysite.com.conf
WSGIPythonPath /Library/Server/Web/Data/Sites/mysite/django-app:/Users/owen/.virtualenvs/mysite:/Users/owen/.virtualenvs/mysite/lib/python2.7/site-packages
<VirtualHost *:80>
ServerName mysite.com
ServerAdmin admin#example.com
DocumentRoot "/Library/Server/Web/Data/Sites/mysite/site"
...
WSGIScriptAlias /api /Library/Server/Web/Data/Sites/mysite/django-app/mysite/wsgi.wsgi
...
<VirtualHost>
It took a lot of putzing for me to get the paths correct (including full path to site-env, which I initially thought would be included automatically after adding the virtualenv top level).
I have a django app that requires some user credentials. I want to send login/register data over HTTPS. I've self-generated a certificate to test out and have also requested an external certificate, though that's pending.
I want to make sure that I don't royally screw up my AWS instance. I've grabbed pieces from different tutorials. For instance, in one tutorial, the SSLCertificateKeyFile was a .pem file but another tutorial had it as a .key file. I could only find a .key file in my dirs, so I just used that. Also, I'm not sure if "IfDefine" conditional is necessary/applicable and I also don't know whether the last line of my SSL virtual host, which seems to be making a change based on sniffing IE, should be included.
My mod-WSGI config normally looks like this:
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /home/dir/
Alias /media/ /home/dir/public_html/media/
<Directory /home/dir/public_html/media>
Options -Indexes
Order deny,allow
Allow from all
</Directory>
Alias /admin_media/ /home/dir/project/admin/
<Directory /home/dir/project/admin >
Order deny,allow
Allow from all
</Directory>
WSGIScriptalias / /home/dir/project/apache/django.wsgi
WSGIScriptalias / /home/dir/project/apache/django.wsgi
<Directory /home/dir/project/apache >
Order deny,allow
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
</VirtualHost>
I've added the following virtual host for https connections:
<IfDefine SSL>
<VirtualHost *:443>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /home/dir/
SSLEngine on
SSLCertificateFile /usr/lib/ssl/www.mysite.com.crt
SSLCertificateKeyFile /usr/lib/ssl/www.mysite.com.key
#SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
</IfDefine>
Does this look about right? Is this sufficient to start requiring https for certain views via a custom decorator? I also want to require https for requests to admin. I've seen the following:
RewriteRule (.*) https://example.com/$1 [L,R=301]
...
I wasn't sure how to make that RewriteRule work without getting rid of Alias-ing. How should I handle that?
Thanks!