I want to use my raspberry pi as a webserver. I installed and configured apache and enabled port forwarding on my router, but it seems that I do something wrong. I really searched a lot before, but I can't find an appropriate answer.
Here is what I've done so far:
Apache
ports.conf:
Listen 80
<IfModule mod_ssl.c>
Listen 443
</IfModule>
apache2.conf
I only added the line
ServerName public_ip
sites-available/default-ssl.conf
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName public_ip:443
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
ServerSignature On
CustomLog /var/log/apache2/access.log combined
LogLevel warn
ErrorLog /var/log/apache2/error.log
</VirtualHost>
I activated the site via
sudo a2enmod ssl
sudo a2ensite default-ssl
iptables
iptables -L
gives me following output:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Netstat
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 64 192.168.1.12:22 192.168.1.10:30007 ESTABLISHED
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::443 :::* LISTEN
Router Thomson TG782
Port forwarding
Firewall on router
Currently deactivated.
Conclusion
http and https works in the LAN. What am I missing?
ServerName
with an IP (at least not under a virtual host with*:443
. Instead use a proper hostname even if it is just in the/etc/hosts
file (e.g.public_ip myserver.mydomain myserver
). Moreover, to get inside a virtual host theHTTP
request must have theHost:
header.http://1.2.3.4:8080
(replacing 1.2.3.4 with your public IP).