You don't have permission to access mp3 file on this server - apache

I have Apache (CentOS) server. If I place some audio file in my directory and run them in my browser then getting 403 forbidden error. The whole scenario is:
I have created a player in Adobe Captivate and published that into HTML and integrated into my Spring Boot application. It is working fine on my local machine but after pushing it to server. I am getting Forbidden Error when my player gets loaded and unable to load audio files (mp3) format.
Below is my configuration file:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/player
<Directory /var/www/html/player>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Redirect / https://www.example.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com$1 [R,L]
ErrorLog /var/log/httpd/eldtplayer-error-log
CustomLog /var/log/httpd/eldtplayer-acces-log common
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
SSLEngine on
SSLCertificateFile /home/cert/ecdl/ssl.cer
SSLCertificateKeyFile /home/cert/ecdl/private.key
SSLCertificateChainFile /home/cert/ecdl/caclient.cer
DocumentRoot /var/www/html/player
<Directory /var/www/html/player>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RequestHeader set X-Forwarded-Proto "https"
</VirtualHost>
screenshot of the issue:

Related

Centos OS https shows apache2 default page

I am setting up my project on centos os, i have installed my ssl certificates and updated my ssl.conf. My project is accessible using http://test.com but when i try to access https://test.com, i can see the site is secure, but it displays the default apache in page. This is despite the fact that i have specified the directory and document root in my 443 virtualhost. Is there a step or error i have, any advise or useful links will be appreciated.
My code looks like this :
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
DocumentRoot "/var/www/html/strategy"
ServerName test.com/
ServerAlias www.test.com
<Directory "/var/www/html/strategy">
RewriteEngine on
# if (HTTP_ACCESS.contains('text/html') && file_not_exists(REQUEST_FILENAME))
RewriteCond %{HTTP_ACCEPT} text/html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [last]
# Any ressources loaded by index.html should behave correctly (i.e: Return 404 if missing)
RewriteRule ^ - [last]
Options Indexes FollowSymLinks
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin info#stratex.com
ServerName www.test.com
DocumentRoot "/var/www/html/strategy"
<Directory "/var/www/html/strategy">
DirectoryIndex index.html
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine On
SSLCertificateFile /home/mydir/certificates/public-cert.pem
SSLCertificateKeyFile /home/mydir/certificates/priv-key.pem
</VirtualHost>
Since i had a ssl.conf file, i removed the conf file for port 443 from the httpd.conf file and i updated the virtual host with port 443 in the ssl.conf file with these details and my app works well.
<VirtualHost *:443>
ServerAdmin info#stratex.com
ServerName www.test.com
DocumentRoot "/var/www/html/strategy"
<Directory "/var/www/html/strategy">
DirectoryIndex index.html
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine On
SSLCertificateFile /home/mydir/certificates/public-cert.pem
SSLCertificateKeyFile /home/mydir/certificates/priv-key.pem
</VirtualHost>

Apache not redirecting https and www

I'm setting up a new example and putting it on a virtual host Apache server (Ubuntu 18.04). I'm having some issues with the Apache configuration because I'm not too familiar with them.
http://example.com, http://www.example.com, https://www.example.com all serve the correct website in its document root.
However, https://example.com serves the document root from main-example.org.
I have also installed an SSL certificate recently and been told to use port 443? It still comes up as "Connection not sure" so I was wondering if this were the case?
Here is the config file in apache2/sites-available:
<VirtualHost *:80>
ServerName main-example.org
ServerAlias www.main-example.org
ServerAdmin it#main-example.org
DocumentRoot /var/www/main-example/build
ErrorLog /var/www/main-example/error_test.log
CustomLog /var/www/main-example/access_test.log combined
<Directory "/var/www/main-example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin it#example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error_test.log
CustomLog ${APACHE_LOG_DIR}/access_test.log combined
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =main-example.org [OR]
RewriteCond %{SERVER_NAME} =www.main-example.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Thanks for your help!
http:// has a default port 80
https:// has a default port 443
Since https uses encryption, if you just put the encryption on 80, all the clients that cannot talk securely will be unable to access yous site (and you'd have to write https://www.example.com:80)
So you have to do something like this:
<VirtualHost *:80>
ServerName main-example.org
ServerAlias www.main-example.org
ServerAdmin it#main-example.org
DocumentRoot /var/www/main-example/build
ErrorLog /var/www/main-example/error_test.log
CustomLog /var/www/main-example/access_test.log combined
<Directory "/var/www/main-example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin it#example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error_test.log
CustomLog ${APACHE_LOG_DIR}/access_test.log combined
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =main-example.org [OR]
RewriteCond %{SERVER_NAME} =www.main-example.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName main-example.org
ServerAlias www.main-example.org
ServerAdmin it#main-example.org
DocumentRoot /var/www/main-example/build
ErrorLog /var/www/main-example/error_test.log
CustomLog /var/www/main-example/access_test.log combined
<Directory "/var/www/main-example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLEngine on
#SSLCipherSuite HIGH
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
SSLProtocol all -SSLv2
SSLCertificateFile "/path/to/ssl.crt"
SSLCertificateKeyFile "/path/to/ssl.k
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
ServerAdmin it#example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error_test.log
CustomLog ${APACHE_LOG_DIR}/access_test.log combined
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLEngine on
#SSLCipherSuite HIGH
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
SSLProtocol all -SSLv2
SSLCertificateFile "/path/to/ssl.crt"
SSLCertificateKeyFile "/path/to/ssl.key"
</VirtualHost>
essentially this means that you are serving he same folder twice. there may be some optimizations to be found.
For more protocols and their standard port numbers see https://opensource.com/article/18/10/common-network-ports or https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Apache Reverse Proxy For Specific Subdomain

I'm have a an Apache HTTP server that has a reverse proxy to a tomcat server. However, I only want the reverse proxy to happen when the client uses the subdomain www. This is because I want to use other subdomains to point to other applications, such as email.
e.g. www.example.com will go display the apache tomcat webapp.
The way to do this, I presume, is to configure my DNS so that every subdomain I use will point to my server. Right now, in addition to www, that is server.example.com and posfixadmin.example.com. However, the issue is that all my subdomains end up pointing to tomcat.
So when I try to visit postfixadmin.example.com/setup.php to set up postfixadmin through its web setup, it ends up taking me to my tomcat webapp's 404.
Here is my virtualhost configuration:
<VirtualHost www.example.com:80>
ServerName http://www.example.com
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
</Virtualhost>
<VirtualHost server.example.com:80>
ServerName server.example.com
DocumentRoot /var/www/html/
RewriteEngine on
RewriteCond %{SERVER_NAME} =server.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} {END,NE,R=permanent}
</VirtualHost>
<VirtualHost postfixadmin.example.com:80>
ServerName postfixadmin.example.com
DocumentRoot /var/www/postfixadmin/public
ErrorLog /var/log/httpd/postfixadmin_error.log
CustomLog /var/log/httpd/postfixadmin_access.log combined
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/postfixadmin/public>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
EDIT
It looks like the proxy conf file doesn't do anything (??). I decided to experiment around and change the first virtualhost servername to the following:
<VirtualHost *:80>
ServerName abcd.example.com
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
</Virtualhost>
Then, I restarted and reloaded Apache...But for some reason, going to www.example.com STILL took me to the tomcat webapp! Does anyone know what drives this?
As to the DNS: I have set specific CNAME entries for each subdomain including www; all of them point back to the public IP of my server that houses my example.com domain (using # in my case - possible with most DNS, I think). There may be some different strategies on this, but I believe you're on the correct path based on what you've suggested in the question.
As to Apache configuration:
I believe that the http protocol does not need to be specified in the ServerName directive and that, generally, the domain need not appear inside the <VirtualHost>...</VirtualHost> tags.
I should mention that I am relatively unfamiliar with Tomcat but am assuming it is listening at 8080 on the localhost, in which case this should help.
I'm not 100% certain that that is all that is snarling you, but try trimming that ServerName back and doing like so, including the change to the VirtualHost open tag:
<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
</Virtualhost>
Your second <VirtualHost> probably requires similar changes, though it also seems that you are directing it to serve requests from the web/network which are coming in on port 8080 -- which I don't believe is your intent.
I think what you want is to also listen on port 80 from the web/network, but to follow these directives if addressed to server.example.com like so:
<VirtualHost *:80>
ServerName server.example.com
DocumentRoot /var/www/html/
RewriteEngine on
RewriteCond %{SERVER_NAME} =server.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} {END,NE,R=permanent}
</VirtualHost>
And finally, similar change to the opening <VirtualHost> tag on the final one:
<VirtualHost *:80>
ServerName postfixadmin.example.com
DocumentRoot /var/www/postfixadmin/public
ErrorLog /var/log/httpd/postfixadmin_error.log
CustomLog /var/log/httpd/postfixadmin_access.log combined
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/postfixadmin/public>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Altogether, this seems more like what you're looking for:
<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
</Virtualhost>
<VirtualHost *:80>
ServerName server.example.com
DocumentRoot /var/www/html/
RewriteEngine on
RewriteCond %{SERVER_NAME} =server.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} {END,NE,R=permanent}
</VirtualHost>
<VirtualHost *:80>
ServerName postfixadmin.example.com
DocumentRoot /var/www/postfixadmin/public
ErrorLog /var/log/httpd/postfixadmin_error.log
CustomLog /var/log/httpd/postfixadmin_access.log combined
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/postfixadmin/public>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I got it!
It turns out that the problem was in the ssl configuration file - the :443 ports were overlapping.
Thanks for the help!

How to serve static files using apache?

I have configured apache 2.2 webserver with tomcat. I want static files of my web application to be served using apache. I made a virtual host entry in httpd.conf
<VirtualHost *:8080>
Alias webcommon_alias C:/webcommon_bk
JkMountFile D:/xampp/apache/conf/myexample.net.properties
ServerName myexample.net
ErrorLog logs/myexample.net-error_log
CustomLog logs/myexample.net-access_log common
<Directory C:/webcommon_bk>
Order allow,deny
Allow from all
RewriteEngine On
RewriteBase /webcommon/
RewriteRule ((.*)\.(js|css|html|gif|png)$) webcommon_alias/$1
</Directory>
</VirtualHost>
But when i fetch this file in browser http://myexample.net:8080/webcommon/img/aboutBox.png i get Object not found! The requested URL was not found on this server.
Try this instead:
<VirtualHost *:8080>
Alias /webcommon C:/webcommon_bk
JkMountFile D:/xampp/apache/conf/myexample.net.properties
ServerName myexample.net
ErrorLog logs/myexample.net-error_log
CustomLog logs/myexample.net-access_log common
<Directory C:/webcommon_bk>
Order allow,deny
Allow from all
RewriteEngine On
RewriteRule ((.*)\.(js|css|html|gif|png)$) /webcommon/$1.$2
</Directory>
</VirtualHost>

Apache Subdomain shows 404 for php files

I have created a subdomain for one of my domains, now I have the following issue:
if I go to blog.domain.com it shows me index.html which is fine
if I go to blog.domain.com/index.html it shows me index.html which is fine
if I go to blog.domain.com/somelog.txt it shows me somelog.txt which is fine
BUT if i try to access any .php file (wordpress) it will show me 404 page not found.
What am I doing wrong? Did I setup apache the wrong way?
the following info in apache/httpd.conf:
<VirtualHost 00.00.00:80>
ServerAdmin info#domain.com
ServerName domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain.com
<Directory /var/www/domain.com>
Order Deny,Allow
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
And this is the newly added subdomain:
<VirtualHost 00.00.00:80>
ServerAdmin info#domain.com
ServerName blog.domain.com
ServerAlias blog.domain.com
DocumentRoot /var/www/domainBLOG
<Directory /var/www/domainBLOG>
Order Deny,Allow
Allow from all
Options -Indexes
</Directory>
</VirtualHost>