Website don't open with https - apache

I have a problem about SSL Certificate on Apache2 virtual host. I have configured my virtual host file correctly so when im trying to reach my website with https://mywebsite.com its ok! But when im trying to reach my website like mywebsite.com its going to default page of hosting ( var/www/html ) not var/www/mywebsite.com/public_html.
I just wanna make who write mywebsite.com always open with https.
If i put on .htaccess file on my default hosting page other websites which directed to host ip will be effected this situation.
Server Spec: Ubuntu 14.04 / Apache2
mywebsite.com.conf
ServerName mywebsite.com
ServerAlias www.mywebsite.com
ServerAdmin hostmaster#mywebsite.com
DocumentRoot /var/www/mywebsite.com/public_html
SSLEngine on
SSLCertificateFile /usr/local/ssl/public.cer
SSLCertificateKeyFile /usr/local/ssl/private.key
SSLCertificateChainFile /usr/local/ssl/intermediate.cer

I solved, i created a new conf file for non-ssl from default conf and set destination of folder to same then i added .htaccess to force https.

Related

Set up Apache with multi-domain server with OVH

My question is related to the wrong redirection of multi-domain server.
I have a VPS server on ovh.com with 2 domains names:
site1.com
site2.com
On OVH admin panel, I have set up the DNS zone so that each site return to the IP adress of the server with a type A. Each www.siteX.com have for targetsiteX.com with a type CNAME.
On the server side, I'm using Apache2 and I have created for all a conf file in /etc/apache2/site-available/:
site1.conf
site2.conf
with the same structure:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName siteX.com
ServerAlias www.siteX.com
DocumentRoot /var/www/siteX
</VirtualHost>
Then I have used the command a2ensite subX.conf or a2ensite siteX.conf and sudo service apache2 restart
The problem I have is that www.site2.com is redirected to site1.com while site2.com is correct and return site2.
The interesting aspect is that www.site2.com? is correctly loading the content of site2 while keeping the www.site2.com/? in the url.
Again, similar to Sub-domain not working, the solution was to disable the default virtualserver:
sudo a2dissite 000-default
Can someone explain the reason ? How to avoid that ?

CentOS HTTPD SSL 404 error

I have a clean install of Linux CentOS on VMWare. Ports 80 and 443 are open in my router. To limit the possible issues, I have temporarily disabled SELinux, and I have stopped the iptables service.
I have followed the directions in the article on setting up an SSL secured Webserver with CentOS: https://wiki.centos.org/HowTos/Https.
Following are the only changes I have made to the default ssl.conf file:
Changes Server name to list my server name
Revised SSLCertificateFile with the name of my .crt file
Revised SSLCertificateKeyFile with the name of my .key file
.
<VirtualHost _default_:443>
ServerName www.example.com
SSLCertificateFile /etc/pki/tls/certs/example.crt
SSLCertificateKeyFile /etc/pki/tls/private/example.key
</VirtualHost>
Using any computer in my LAN, I am able to get both HTTP(80) and HTTPS(443) Web pages from my HTTPD Web server. When using a computer on a different network, I can get HTTP(80) pages. However, HTTPS(443) pages produce "error 404 the requested resource is not found."
Getting an HTTP(80) page using a computer in a different network, I see connections in this log:
/var/log/httpd/access_log
Requesting an HTTPS(443) page using a computer in a different network, these logs do not contain any new events:
/var/log/httpd/access_log
/var/log/httpd/error_log
/var/log/httpd/ssl_request_log
/var/log/httpd/ssl_access_log
A Wireshark capture on the client does not show any relevant HTTP(80), HTTPS(443) or SSL packets.
Since the logs are not showing events when requesting HTTPS(443) Web pages, and Wireshark is also not capturing packets, I am not certain where to turn next to diagnose this issue. If there are any tips or suggestions on a way to diagnose the issue, I would definitely be appreciative.
I was able to solve this issue. The directions in this article provided the fix: https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-httpd-secure-server.html.
Originally, my ssl.conf file did not have www or .com in the domain name, like this:
<VirtualHost _default_:443>
ServerName www.example.com
SSLCertificateFile /etc/pki/tls/certs/example.crt
SSLCertificateKeyFile /etc/pki/tls/private/example.key
</VirtualHost>
I noticed in the CentOS documentation that www and .com was being used. I created a new certificate and private key, and then updated the ssl.conf file.
<VirtualHost _default_:443>
ServerName www.example.com
SSLCertificateFile /etc/pki/tls/certs/www.example.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/www.example.com.key
</VirtualHost>
Now I am no longer getting error 404 when requesting the Web page on a remote network. This taught me that there are specific requirements in the format of the certificate, private key, and ssl.conf file.

dynamically support multiple SSL sites for one IP address

For a web application running on Tomcat, to support multiple SSL sites on one Ip address, I like to add Apache in front of Tomcat.
Is it possible for user to upload its own SSL certificate and configure it dynamically without server restart?
<VirtualHost *:443>
DocumentRoot
ServerName
SSLCertificateFile
SSLCertificateKeyFile
SSLCACertificateFile
SSLEngine on
</VirtualHost>
For apache, the SSL configuration above needs to be added into apache conf file,
and requires server restart. Server restart is not acceptable because there will be many users on the same server. Any solution?
Thanks for help.

Multiple web applications with Apache 2.4

I want to have two webapps (webapp1 and webapp2 resident under /var/www/html/webapps/), both using PHP and JSP, running on the same machine:
Apache 2.4
Tomcat 7.0.50 (+APJ connector)
and want to make them accessible through the following URLs (with identical IP and ports):
localhost/webapp1
localhost/webapp2
I am aware of Virtual Hosts facility. The problem is that Apache seems to "see" only the first site available: whenever I look for localhost/webapp2, I get a 'Not Found' error. Note that if I look for "localhost:8080/webapp2" (i.e., bypassing apache2) everything works fine.
Each webapp has its own conf file under sites-available directory. For example, in webapp2.conf I have
JkMountCopy On
JkMount /webapp2/* tomcat_worker
How can I solve?
From the documentation
Note
Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.
Listen 80
Listen 8080
<VirtualHost 172.20.30.40:80>
ServerName www.example.com
DocumentRoot "/www/domain-80"
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.com
DocumentRoot "/www/domain-8080"
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example.org
DocumentRoot "/www/otherdomain-80"
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.org
DocumentRoot "/www/otherdomain-8080"
</VirtualHost>
If you want additional help, show us your configuration files related.

Set up host file using port

I want to setup my host file to
127.0.0.2:5050 domain2.com => this is a local domain
when a type in my browser domain2.com, this return me : HTTP Error 404. The requested resource is not found.
i use this in apache
<VirtualHost 127.0.0.9:5050>
ServerAdmin info#domain2.com
DocumentRoot "C:/Users/My_Dir/LOOP/WebEnginer-2011/domain2_Dir/"
ServerName domain2.com
DirectoryIndex index.php index.html index.htm
ServerAlias www.domain2.com
ErrorLog "c:/wamp/xxxx/xxxx.log"
CustomLog "c:/wamp/xxxx/xxxx.log" common
</VirtualHost>
<VirtualHost 127.0.0.9:5050>
ServerAdmin info#domain2.com
DocumentRoot "C:/Users/My_Dir/LOOP/WebEnginer-2011/domain2_Dir/admin_Dir/"
ServerName admin.domain2.com
DirectoryIndex index.php index.html index.htm
ServerAlias www.admin.domain2.com
ErrorLog "c:/wamp/xxxx/xxxx.log"
CustomLog "c:/wamp/xxxx/xxxx.log" common
</VirtualHost>
but when i type 127.0.0.2:5050 i can see a web page. I want to use subdomain like admin.domain2.com
i can't use port 80 because IIS use that port.
How can i set up my host file to listen domain2.com?
That won't work since the hosts file only serves the purpose of mapping a hostname to an IP-address. The port number of a service is a different concept and is not handled by the "hosts" file nor the DNS-System. In Short: you can't supply a port number in the "hosts" file.
If your Webserver works on another port, you have to supply that information in the URL: http://domain2.com:5050.
The only other solution is to configure your Webservers to listen on a specific IP so that they don't interfere with each other. For example the IIS could listen on 127.0.0.1 and the Apache on 127.0.0.2 (the way you have already configured it).
There's a HOWTO for achieving that with the IIS. I'm not sure if that works for 127.0.0.x-IP's but I think it's worth a try.
It might be:
Your DNS resolver not resolving that properly
Some Apache webserver misconfiguration
Try this to get more information about that:
What if you ping domain2.com?
Also, try what happens if you put something like domain2.local in your hosts file. It might be some windows security c** disallowing you to overwrite the ip of an existing domain.
Why didn't you use 127.0.0.1? That should be fine, however
Make sure you have a properly configured VirtualHost that accepts requests to "domain2.com", or you just have a default virtualhost.
EDIT
What did you actually add to hosts file? The correct syntax would be:
127.0.0.2 domain2.com