I spent last 2 days trying to find the solution to my issue.
HTTP works fine http://jackrus.net, but HTTPS won't work.
1.I created an instance on Amazon Linux EC2.
2.Redirected my domain jackrus.net to my public IP
3. Opened listeners 443, 22, 80. (security groups)
4. Followed the instructions from aws documentation from here
5. Checked all permissions
6. apachectl -t - says syntax is fine.
7. Restarted the server. no problem here too.
Here is my ssl.conf
....
....
....
SSLCertificateFile /etc/pki/tls/certs/certificate.crt
SSLCertificateKeyFile /etc/pki/tls/private/private1.key
SSLCACertificateFile /etc/pki/tls/certs/intermediate.crt
...
...
...
The response i get here:
This site can’t be reached
jackrus.net refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
You might need to add your virtual host to your http/config.d file
You can check what vhosts you have running like this:
apachectl -t -D DUMP_VHOSTS
Look up where your config could be
find /etc/httpd -name *.conf
then edit you config with vim or nano or whatever you prefer
vi /etc/httpd/conf/httpd.conf
Add your virtual host ( type i first to insert if in vim)
#Virtual Host added
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName "example.com"
ServerAlias "example"
RewriteEngine on
RewriteCond %{SERVER_NAME} =example
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
to save and exit:
:wq
then try restarting the server.
I also recommend the letsencrypt certbot-auto for a quick solution as it has a debug feature to tell you exactly what the error is. If you are using Letsencrypt then you sould look up the ACMEv1 to v2 upgrade or end of life cycle for ACMEv1
Related
I know in Apache, there are virtual hosts. When a request is given, it goes and search between these virtual hosts to see if there are server name like request. It takes its option back like document root and others I have this file in /etc/httpd/sites-enabled:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/example.com/html
ErrorLog /var/www/example.com/log/error.log
CustomLog /var/www/example.com/log/requests.log combined
</VirtualHost>
I defined all directories as well like /var/www/example.com/html and after all that, I have a file named /etc/httpd/conf at its last line I added this code:
Include sites-enabled/*.conf
After that when I restart httpd it performs complete with no errors, but it doesn't work and it goes to its default root. Where is the problem?
Once you create a virtual host configuration file, in your example, /etc/apache2/sites-available/example.com.conf
You need to use the command as super user
a2ensite example.com
And then restart Apache:
systemctl reload apache2
You can tell what virtual hosts are up and running by the command:
apache2ctl -S
i solve it just with replacing star with my local ip in linux in virtualhost tag
<VirtualHost ip:80>
after too many examination it works finally.there was no problem in other places.
I am using laravel5.5 and I'm implementing the wild card dns giving each user their own sub-domain.
In my implementation, I am working on a laptop with windows 10 and a laragon server.
On laragon I setup like this
<VirtualHost *:80>
DocumentRoot "C:/laragon/www/tindahan/public/"
ServerName tindahan.local
ServerAlias *.tindahan.local
<Directory "C:/laragon/www/tindahan/public/">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and on the host file
127.0.0.1 tindahan.local
127.0.0.1 fil.tindahan.local
127.0.0.1 liz.tindahan.local
On the route
Route::get('/', function () {
$url = parse_url(url()->current());
$domain = explode('.', $url['host']);
$subdomain = $domain[0];
dd($subdomain);
});
So when visiting the fil.tindahan.local or liz.tindahan.local, I got the result
fil and Liz
but if I visit joseph.tindahan.local I got this error
This site can’t be reached
I need to create another sub-domain on the host to make it work.
The question is, how can do it automatically?
when I enter any names as a sub-domain it should be automatically created so that I never do it manually?
As far as I know, the error will resolved in network layer, not from application layer (in this case laravel).
I think you need your own local DNS-Server.
I've used dnsmasq in Linux (ubuntu) and it worked fine.
steps:
apt install dnsmasq
open /etc/dnsmasq.conf with an editor.
add address=/your_domain.loc/127.0.0.1 (it's just an example so you'll need change domain and ip probably).
run sudo systemctl restart dnsmasq to restart the service.
Well, you can test any url from your_domain.loc in your browser and you will not get that error ;)
goodluck
I'm trying to figure out how to have the website function after i point the DNS to the server.
by default, (after fresh install of apache, mysql, php) the main server directory is situated at var/www/html so if i upload test html file, via default server ip the html file will show.
i'm trying to setup a custom folder i.e var/www/examplewebsite.com/public_html and then the public_html would function as the go-to folder for when user goes to my website. Multiple websites on one IP (server) would be great too
i found some information from http://bit.ly/1kguprn but i do not see the NameVirtualHost and the paragraph under that.
I'm a newbie to the Centos/Linux environment, any help would be greatly appreciated :)
You have a nice tutorial here: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-6
Basically, create a folder and an index for testing purposes:
sudo vi /var/www/example.com/public_html/index.html
add the Virtual directive in your apache config file (:
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
ServerAdmin webmaster#example.com
DocumentRoot /var/www/example.com/public_html
ServerName www.example.com
ServerAlias example.com
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/requests.log
</VirtualHost>
Restart apache:
sudo service httpd restart
Check this documentation for Centos 7. They have a nice initial tutorial.
https://www.digitalocean.com/community/tutorials/an-introduction-to-selinux-on-centos-7-part-2-files-and-processes
First, I will recommend to you that check if you have the httpd service installed and active.
sudo service httpd status
if non active
sudo service httpd start
once active
Check the if the ports 80 and 443 (https are active)
sudo netstat -tulnap | grep :80
sudo netstat -tulnap | grep :443
if they are active, test the server. http://yourserverip or https://yourserverip
By default it should go to the apache webserver page.
Once you can see the page. Try to create the initial index.html page in
/var/www/html
vi /var/www.html/index.html
click i for insert
copy the following html
Test
Test web page
In the tutorial, they will explain the rest of the configuration.
#Moderator The tutorial provide a good long material for the reader, I got punish for answer correctly by the moderator. I think the website are long enough to clarify the question and I think copy again the tutorial here is not proper answer.
Also check the next documentation for changes between Apache 2.2 and 2.4
https://linode.com/docs/security/upgrading/updating-virtual-host-settings-from-apache-2-2-to-apache-2-4/
If you have any problems, comment here.
I am able to establish a websocket connection, from a clienJS to NodeJs. But fails to connect websocket, when the request pass through apache httpd.
Using Httpd2.4.7, I am getting the below error. Please let me know what needs to be corrected.
WebSocket connection to 'ws://172.27.38.86/socket.io/1/websocket/_uW8Sv7lgQfrZncTSzKu' failed: Error during WebSocket handshake: Unexpected response code: 502
Thanks & Regards
Jawahar
Apache SUCKS at handling websockets through proxies. I recommend either getting rid of the Apache layer, or modifying your socket.io settings to use XHR polling.
After 2.4.5, apache included a module called proxy_wstunnel on their trunk, not available yet on current ubuntu production versions of apache (2.4.7). It was somehow painful, but following roughly the steps listed on this blog-post I managed to install the module and use it successfully.
dpkg -s apache2 //this gives you the version of apache in my case "2.4.7-1ubuntu4.1"
//then you checkout that version of apache
svn co http://svn.apache.org/viewvc/httpd/httpd/tags/2.4.7/
//you get into the directory just checked out
cd 2.4.7
//in there you checkout the Apache Portable Runtime Project and utils
svn co http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x srclib/apr
svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/1.3.x srclib/apr-util
//you compile with the corresponding modules flags
./buildconf
./configure --enable-proxy=shared --enable-proxy_wstunnel=shared
make
//You copy the modules (mod_proxy and mod_proxy_wstunnel) to your apache working copy
//It could be advisable to backup the old mods first
sudo cp modules/proxy/.libs/mod_proxy{_wstunnel,}.so /usr/lib/apache2/modules/
sudo chmod 644 /usr/lib/apache2/modules/mod_proxy{_wstunnel,}.so
sudo echo -e "# Depends: proxy\nLoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so" | sudo tee -a /etc/apache2/mods-available/proxy_wstunnel.load
//you then enable your module and restart your apache... so now the module is ready to use
sudo a2enmod proxy_wstunnel
sudo service apache2 restart
and after all that, researching a little bit I found this page I configured my apache vhost file accordingly like this
<VirtualHost *:80>
ServerAdmin yourmail#mail.com
ServerName yoursubdomain.yourdomain.info
Redirect permanent / https://yoursubdomain.yourdomain.info
</VirtualHost>
<VirtualHost *:443>
ServerAdmin yourmail#mail.com
ServerName yoursubdomain.yourdomain.info
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
//these next two lines are to enable the wstunnel
ProxyPass /socket.io/1/websocket ws://localhost:9091/socket.io/1/websocket
ProxyPassReverse /socket.io/1/websocket ws://localhost:9091/socket.io/1/websocket
//this line is to retrieve the socket.io.js to use
ProxyPass /socket.io/ http://localhost:9091/socket.io/
SSLEngine on
SSLCertificateFile /etc/ssl/certs/yourcert.crt
SSLCertificateKeyFile /etc/ssl/private/yourcert.key
SSLCertificateChainFile /etc/ssl/certs/your_bundle.crt
//your logs
CustomLog /var/log/apache2/yoursubdomain.yourdomain.info.log combined
ErrorLog /var/log/apache2/yoursubdomain.yourdomain.info.error.log
</VirtualHost>
And TaDaaa... I have a working node websocket responding on port 9091 through an apache proxy that gets everything trough the 443 standard ssl port.
I suppose ubuntu will soon include this module on their production version, but meanwhile this is the way to go
I had to setup ws tunnel in CentOs, where apache 2.2.15 was installed by default.
I have tried patching proxy_wstunnel module with apache 2.2.15. But no help. Finally I have decided to remove apache 2.2.15 and install apache 2.4 by following the official documentation from http://httpd.apache.org/docs/2.4/install.html
After installation (I have installed in the default location /usr/local/apache2/), I did the following to get tunneling work
uncomment the following lines from /usr/local/apache2/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
Add a virtual host for tunneling websocket requests
<VirtualHost *:80>
ServerName subdomain.mydomain.com
ProxyPass / ws://localhost:8081/
ProxyPassReverse / ws://localhost:8081/
</VirtualHost>
from my frontend the websocket is connected via ws://subdomain.mydomain.com:80
restart apache using
sudo /usr/local/apache2/bin/apachectl -k restart
I have set up a linux box mainly for testing and I have got to a stage were apache, mysql and php are running. I followed tutorials on how to set up virtual hosts so I can point domains to it but something strange is happening.
This is my httpd-vhosts.conf file that I have included in my httpd.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName thedomain.co.uk
DocumentRoot /var/www/thedomain
</VirtualHost>
When I go to thedomain.co.uk it is pointing to the correct place as you'd expect. But when I go to my servers ip, internal or external it is going to the same directory as the virtual host. Could you guys think of any reason that is? I would expect it to go to /var/www/html by default? Oh and I'm running CentOS 6.3
Thanks in advance for any answers!
You have used wildcard to point everything at DocumentRoot /var/www/thedomain
You need to create second listing :
<VirtualHost myotherdomain.co.uk:80>
ServerName myotherdomain.co.uk
DocumentRoot /var/www/myotherdomain
</VirtualHost>
where your other domain is whatver ip and the document root, points to your choise.
The first vhost listing is also used as the default ... so if you were to use localhost it would resolve to whatever is first in list.