How enable mod_xsendfile? - apache

I installed mod_xsendfile on the apache server, How can I enable this module for the user correctly in Ubuntu 18.04.5 LTS? I need to edit the apache main config file or user config file? Anyone, please help me with it?
here is the user apache configuration
<Directory "/home/users/rowan/www/">
Require all granted
Options FollowSymLinks
</Directory>
# domain.com
<VirtualHost *:80>
ServerName domain.com
ServerAdmin test#gmail.com
DocumentRoot "/home/users/rowan/www/"
SuexecUserGroup "rowan" "rowan"
# log
LogLevel warn
CustomLog "/home/users/rowan/logs/access.log" keyhelp_log
ErrorLog "/home/users/rowan/logs/error.log"
# php support
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php/keyhelp_rowan.socket|fcgi://keyhelp_rowan.socket"
</FilesMatch>
# Set some proxy properties (the string "unique-domain-name-string" should match
# the one set in the FilesMatch directive.
<Proxy fcgi://keyhelp_rowan.socket>
ProxySet connectiontimeout=5 timeout=600000
</Proxy>
<Directory "/home/users/rowan/www/">
AllowOverride All
Options -Indexes
CGIPassAuth On
</Directory>
</VirtualHost>

Related

Why isn't my apache httpd server serving content from my VirtualHost

I have an apache httpd server running on a linux server. The server's fqdn is www.example.com, but I have a dns alias of www.example2.com for the same server.
When I access the server using my browser and use http://www.example.com it serves the correct content, but if I use http://www.example2.com, I get the default content from my /var/www/html folder not the content from the /var/www/html2 folder.
A stripped-down copy of my httpd.conf file follows:
ServerName www.example.com:80
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
CustomLog "logs/access_log" combined
ErrorLog "logs/error_log"
LogLevel warn
<VirtualHost www.example2.com:80>
ServerName www.example2.com:80
DocumentRoot /var/www/html2
CustomLog "logs/access_log2" combined
ErrorLog "logs/error_log2"
<Directory "/var/www/html2">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.example2.com
DocumentRoot /var/www/html2
CustomLog "logs/access_log2" combined
ErrorLog "logs/error_log2"
<Directory "/var/www/html2">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
The VirtualHost tag is for IP based filtering, to filter by host\server name use the ServerName directive.

Hosting ASP.NET Core as root and static websites as subdirectories

I'm currently struggling with the following problem. I have Ubuntu server with apache2 installed, on which I host many static websites. Some of them are sub-folders e.g www.somedomain.com/userWebsite1 and others as symlinks e.g. www.somedomain.com/~user4. I also want to host asp.net core app as root e.g. www.somedomain.com/. Unfortunately, if set this via virtual host my static sites not working (404 not found). Maybe there is an option in asp.net app to force search static sites if url is not found in ASP.NET app? Currently, I cannot host static sites in sub-directories and my ASP.NET Core App simultaneously :( Any help is appreciated. :)
My 000-default.conf file
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5010/
ProxyPassReverse / http://127.0.0.1:5010/
ServerName somedomain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ServerAlias www.somedomain.com
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
php_admin_value engine On
</Directory>
<Directory /home/*/public_html>
Options +IncludesNoExec +SymLinksIfOwnerMatch
Order allow,deny
allow from all
</Directory>
#<Location / >
# ProxyPreserveHost On
# ProxyPass http://127.0.0.1:5010/
# ProxyPassReverse http://127.0.0.1:5010/
#</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Apache Symfony Vitrual Host

I clone project in /home/ivan/host/name/web and create virtual host. a2ensite and reload and restart server.
<VirtualHost *:80>
ServerName name.local
DocumentRoot /home/ivan/host/name/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/name-error.log
CustomLog /var/log/apache2/name-access.log combined
<Directory "/home/ivan/host/name/web">
AllowOverride All
Allow from All
</Directory>
and hosts
127.0.0.1 name.local
but have
Forbidden
You don't have permission to access / on this server.
I doing chmod 777 -R host/ but still have error
what I'am doing wrong ?
SOLVED
<VirtualHost *:80>
ServerName aog.local
DocumentRoot /home/ivan/host/name/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/name-error.log
CustomLog /var/log/apache2/name-access.log combined
<Directory "/home/ivan/host/name/web">
AllowOverride All
Require all granted
Allow from All
</Directory>
Look like you are using apache 2.4,
add directive Require all granted as shown below:
<Directory /home/ivan/host/name/web>
AllowOverride All
Options +FollowSymlinks
Require all granted
</Directory>

Moodle apache proxy

I'm having troubles setting up a moodle instance behind an apache proxy.
Here's my apache front-end that proxies to the running server.
NameVirtualHost www.example.com:443
<VirtualHost www.example.com:443>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias www.example.com
ProxyPass / http://192.168.1.101/
ProxyPassReverse / http://192.168.1.101/
SSLEngine on
SSLCertificateFile /etc/ssl/crt/example.com.crt
SSLCertificateKeyFile /etc/ssl/crt/example.com.key
SSLCACertificatePath /etc/ssl/crt
SSLCertificateChainFile /etc/ssl/crt/example.com.bundle.crt
</VirtualHost>
On the concrete server I've got.
$CFG->wwwroot = 'http://192.168.1.101/classes';
And
<VirtualHost 192.168.1.101:80>
ServerAlias 192.168.1.101
ServerAdmin webmaster#localhost
ServerName 192.168.1.101
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
The thing is that I keep getting that moodle is only accessible from 182.168.1.101 something is not quite matching the expected. I've been able to configure confluence and other platforms but moodle doesn't work.
The concrete error is as follows.
Incorrect access detected, this server may be accessed only through "http://192.168.1.101/classes" address, sorry. Please notify server administrator.
Does anyone know what might be happening?
Its a Moodle error message, the wwwroot in config.php has to match.
You could try
$CFG->wwwroot = 'http://' . $_SERVER['HTTP_HOST'];
Although this might not allow some command line updates in Moodle.
On the proxy server, modify the VirtualHost entry as follows:
ProxyPass / http://192.168.1.101/classes
ProxyPassReverse / http://192.168.1.101/classes
For Moodle, what you set in Moodle's config.php for
$CFG->wwwroot
...has to match your ProxyPass and ProxyPassReverse values in the VirtualHost definition on the Proxy server.
So, what's the URL that points to your front end?
That's what you need to set $CFG->wwwroot to.

Apache Reverse Proxy not rewriting URLs the way I expect

I am pretty new to Apache and was hoping to setup a reverse proxy to be able to access so the web interfaces of some IP Cameras I have from one site. The basic layout I'm using is below:
/ Cam 1 - 192.168.1.10
Reverse Proxy - 192.168.1.6 -
\ Cam 2 - 192.168.1.11
When I click a link it doesn't resolve correctly, the URL should be http://192.168.1.6/cam1/settings.htm but it resolves to http://192.168.1.6/setting.htm
Not Found
The requested URL /setting.htm was not found on this server.
Apache/2.2.22 (Debian) Server at 192.168.1.6 Port 80
My Config is here, I'm using the standard httpd.conf with the proxy and rewrite modules enabled:
ProxyRequests off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
<VirtualHost *>
Servername webserver
RewriteEngine on
RewriteRule ^/cam1/(.*)$ http://192.168.1.10$1 [P]
RewriteRule ^/cam2/(.*)$ http://192.168.1.11$1 [P]
ProxyPass /cam1 http://192.168.1.10
ProxyPassReverse /cam1 http://192.168.1.10
ProxyPass /cam2 http://192.168.1.11
ProxyPassReverse /cam2 http://192.168.1.11
</VirtualHost>
Any help would be appreciated.
Cheers,
Adam
In logs you can clearly see that there are some files missing like File does not exist: /var/www/jpg and /var/www/lang so may be this is the reason for your storage issue.I bet you that you missed some configuration while server OR your server msy corrupt these files while running due to some other files.I suggest you to fresh download and then reinstall it.
For future users:
cat /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin user#work.com.br
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from 192.168.5.25
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass /cameras/ http://192.168.5.6/
ProxyPassReverse /cameras/ http://192.168.5.6/