Closed InterstellarScout closed 5 years ago
Are you using an htaccess file?
Yes, both programs I am trying to run have .htaccess files. One of them simply contains "Options -indexes" while the other is more advanced with a lot of </ IfModule >'s
Add Allowoverride to your apache config on the Directories that contain the htaccess files. See below example:
<Directory /var/www/sitedir/>
AllowOverride All
</Directory>
Restart apache and let me know of that works.
Alright, just in case I did something wrong, I am going to tell you what I did. I added what you showed above to /etc/apache2/apache2.conf Since I am working with two of these programs, I added two of them for each directory. Upon restarting apache, I found that the results were the same. To make sure the results are authentic, I accessed the page from two different web browsers and another computer. Unfortunately it did not fix it. Since these programs are out of the box, i find it hard to imagine they may be responsible.
Some more information about how I have apache set up, I have set up three virtual hosts which are each accessible when i direct to them. This is being run on Ubuntu 18.04. It's odd, the basic HTML works fine, but when i direct to those directories with the .htaccess files, it gives me that message.
Try to access again, and see what the apache error logs say.
Interesting: I am getting an error relating directly to each .htaccess of each directory when I attempt to access.
/var/www/blah/blah/nextcloud/.htaccess: <IfModule not allowed here, referer: http://domain.net/interstellarcloud.html
The above and below html referrer redirects to the index.php.
/var/www/blah/blah/MessagingSystem/.htaccess: Options not allowed here, referer: http://domain.net/chatroom.html
OK i see you told me you are using Vhosts, so this means you have a configuration file for each of these vhosts. So try to add the override on the specific vhost file, Example,
/etc/apache2/sites-enabled/site.com.conf
<VirtualHost *:80>
ServerAdmin email.com
ServerName site.com
ServerAlias www.sie.com
DocumentRoot /var/www/html/site.com/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/site.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =site.com [OR]
RewriteCond %{SERVER_NAME} =www.site.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
To clarify, under the RewriteEngine on, other than changing site.com and www.site.com, does anything else need to be fixed? I'm unsure about {Server_Name}. Would that need to be changed to the above ServerName?
Also since I have two subfolders in the main site directory containing the .htaccess files, do I need to make a < Directory > for each or can i just use the one to < /Directory ...site.com/public_html >
Use the top level directory for the override and change site.com to your appropriate one.
Ah hah, progress! Instead of the maintenance message, I am receiving a refused connection. This is odd now because the owner is www-data and (for testing purposes) I made one of them with all 777 permissions. What would cause the connection to be rejected when attempting to access those directories?
Go to the apache error logs
The existence of the logs are glorious. Alright, the virtual host is not working for that specific site now where other sites are running fine. The log is full of different notices from sources. I have ModSecurity compiling, and
[Thu Jun 27 14:44:09.429862 2019] [mpm_prefork:notice] [pid 2111] AH00171: Graceful restart requested, doing restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' d irective globally to suppress this message
[Thu Jun 27 14:44:10.030045 2019] [:notice] [pid 2111] mod_qos(009): loaded MPM is 'prefork' but mod_qos should be used with MPM 'Worker' only.
[Thu Jun 27 14:44:10.031107 2019] [mpm_prefork:notice] [pid 2111] AH00163: Apache/2.4.29 (Ubuntu) mod_qos/11.44 mod_wsgi/4.5.17 Python/2.7 configured -- resuming normal operations
[Thu Jun 27 14:44:10.031129 2019] [core:notice] [pid 2111] AH00094: Command line: '/usr/sbin/apache2'
Each time I restart I get the above, but nothing stands out to me as responsible for preventing connections to the site entirely. Wouldn't it have a problem restarting if there were a syntax error? If that's not the case, what is the additions that we made would affect connections to the virtual host?
ModSecurity can get in the way depending on the webapp you are accessing, so try to put it on detection only. You can accomplish this by running the command
sed -i s/SecRuleEngine\ On/SecRuleEngine\ DetectionOnly/g /etc/modsecurity/modsecurity.conf
Hmm unfortunately even after that it is still refusing the connection.
Alright so I have kept playing with it and got the site back up by removing everything under < /Directory >, so I took out the rewrite engine stuff. Doing so has allowed me access back to that VirtualHost. The above change that we made has now enabled me to have the Options in the .htaccess file, so yay! Half of the problem is solved. Now I am getting the same error that we got before as seen below:
/var/www/blah/blah/nextcloud/.htaccess: <IfModule not allowed here, referer: http://domain.net/interstellarcloud.html
You can see the .htaccess from NextCloud's Github here in case that helps Is there a way to fix/circumvent this?
Will deploy a test server with this and try to pinpoint what might be happening.
I really appreciate your help with this! If you need anything I'll be here playing with it.
I have found a solution and got it working. My final .conf file looks like this:
<VirtualHost *:80>
ServerAdmin admin@site.net
ServerName site.net
ServerAlias www.site.net
DocumentRoot /var/www/html/site.net/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/site.net/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
</VirtualHost>
I now have both programs operating as they should. Thank you a lot for the technical troubleshooting and leads, Jsitech. You have great stuff here.
Greetings! Thank you so much for this script. I love the tools that it includes which have made a great research project.
I have encountered an issue where every time I try to run anything php, the server returns: "Tareas de mantenimiento en curso. Disculpe las molestias" It's very hindering when my LAMP server cannot do as intended, so I am trying to figure out what is responsible for coming back with it. When I looked into it, I found that the message comes up when there is a "ErrorDocument 500." Even when I changed all directories to have permissions 777, the message remained. It's not a permissions issue. Any ideas on how to fix it so I can run my web programs?
Thank you!