Permission denied on Centos7, Apache, Mod Passenger and Ruby 2.6.3 - css

I never tried working with Cent-OS for hosting my Rails applications. I was using before and now I got a server which is running Cent-OS 7. I installed Apache, Phusion Passenger, RVM, Ruby 2.6.3 and bundle updated the Rails app. Everything was fine up to this.
I added the Virtual-Host and restarted the Apache2 server, I got 403 Forbidden message from the browser.
Also I checked the error_log I got the following errors.
[Tue Feb 11 08:34:14.377938 2020] [core:error] [pid 125490] (13)Permission denied: [client 172.69.78.16:30474] AH00035: access to / denied (filesystem path '/home/santosh/sites') because search permissions are missing on a component of the path
[Tue Feb 11 08:34:14.593925 2020] [core:error] [pid 125490] (13)Permission denied: [client 172.69.78.16:30474] AH00035: access to / denied (filesystem path '/home/santosh/sites') because search permissions are missing on a component of the path
The virtual host:
<VirtualHost *:80>
ServerName domain.com.np
ServerAlias www.domain.com.np
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# ModPagespeed on
# Tell Apache and Passenger where your app's 'public' directory is
DocumentRoot /home/santosh/sites/app/public
PassengerRuby /home/santosh/.rvm/gems/ruby-2.6.3/wrappers/ruby
# Relax Apache security settings
<Directory /home/santosh/sites/app/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
And the permission of the app directory is as:
drwxrwxr-x. 4 santosh santosh 31 May 18 2019 app
I couldn't figure out what I am missing. Please help me.

Have you checked the folder permissions on the server, try running 'ls -l' on your folder.

Related

The web application does not display using apache server in linux

I am trying to create a web application using dotnet 3.1 and httpd 2.4 with a proxy server but no mater what how the configuration files are the web application is not displayed.
I am using a Fabian with rhel 7.
The following are the configuration file located in the folder /etc/httpd/conf.d/,
<VirtualHost *:80>
ServerName 22.xx.xxx.xx
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
RewriteRule /(.*) ws://127.0.0.1:5000/$1 [P]
ErrorLog /var/log/httpd/netcore-error.log
CustomLog /var/log/httpd/netcore-access.log common
</VirtualHost>
My service file located at /etc/systemd/system and is as follows, i hade ensure that the location of the dotnet location is as follows as it was not installed in the standard location. Additionally the root user has been given all required permission
[Unit]
Description=ASP .NET Web Application
[Service]
WorkingDirectory=/var/netcore/publish
ExecStart=/opt/rh/rh-dotnet31/usr/bin/dotnet /var/netcore/publish/Test.dll
Restart=always
RestartSec=10
SyslogIdentifier=netcore-demo
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
Additional info:
-The error log at location /var/log/httpd/netcore-error.log displays no errors but I no the server has atleast received a request from the following log in the access log
-The access log only shows the following 22.xx.xxx.xxx -- [Date and Time] "GET /HTTP/1.1" 307 -
I have turned of the firewalld.service and configured the IPtable.
When I use curl, there is no response.
Dotnet is listening in port 5000 and 5001, not sure why?
Apache is listening in port 80
When run the application from with dotnet command it seem to work, there does not seem to a problem with the application.
Have tried without specifying the server name and still had no change
Any help would be appreciated as have been stuck on this problem for 2 weeks now.
Just an update - turns out it was a problem with the code/configuration. I think it was called launchsetting.json file, which forcefully made the connection a HTTPS and forward it to the wrong port. Just had to remove that section and all was good.

Shiny-Server with Apache WebSocket fail

I'm new to servers. I installed an Apache web server on Ubuntu 20.04, with and secured the connection with Let's Encrypt. Then I set up a Shiny server (latest Version) and set up the following forwarding in Apache (according to the template).
<Proxy *>
Allow from localhost
</Proxy>
RedirectMatch permanent ^/app$ /app/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /app/(.*) ws://localhost:3838/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /app/(.*) http://localhost:3838/$1 [P,L]
ProxyPass /app/ http://localhost:3838/
ProxyPassReverse /app/ http://localhost:3838/
Header edit Location ^/ /app/
ProxyRequests Off
I can call up my Shiny-app on my mobile phone as well as on the desktop at home (everything works). In our company network, it loads the website first, but not the interactive parts - and then the entire page turns gray.
Based on research, it appears to be a problem with the websockets and the firewall oft the company. The same app on shinyapps.io works. I can find the following error message in the web browser:
sockjs-0.3.4.min.js:27 WebSocket connection to 'wss://srv.socialthink.net/app/uster-kultur/__sockjs__/n=kNUaoWz4VkbEoGT2f8/464/b_7zv2u0/websocket' failed:
I found a similar description of the problem, but no workaround to fix the problem.
I don't know how to continue looking, are there any ideas?

Error AH00124 during Symfony 4 server configuration

I currently am trying to deploy my Symfony 4 website on a hosted VPS, I did setup everything quite successfully, installed Apache2, PHP 7.2, MySQL server and phpmyadmin.
I then started configuring my server acordingly to host a Symfony 4 website, and before deploying my own application I tried to deploy a smaller one so that I would know that at least some part worked with a no-database no-bundles application.
When I try to access my website nothing happens, the following error log is generated in /var/log/apache2 :
[Wed Jul 11 14:06:08.580654 2018] [core:error] [pid 13404] [client 37.97.69.85:52997] AH00124: Request exceeded the limit of 10 internal redirects due to probable
configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:06:41.901738 2018] [php7:error] [pid 13423] [client 37.97.69.85:44931] PHP Fatal error:
Uncaught Symfony\\Component\\Dotenv\\Exception\\PathException: Unable to read the "/var/www/releases/20180710151554/public/../.env" environment file.
in /var/www/releases/20180710151554/vendor/symfony/dotenv/Dotenv.php:54\nStack trace:\n#0 /var/www/releases/20180710151554/public/index.php(15):
Symfony\\Component\\Dotenv\\Dotenv->load('/var/www/releas...')\n#1 {main}\n thrown in /var/www/releases/20180710151554/vendor/symfony/dotenv/Dotenv.php on line 54
[Wed Jul 11 14:33:33.702774 2018] [core:error] [pid 13442] [client 37.97.69.85:53026] AH00124: Request exceeded the limit of 10 internal redirects
due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:38:07.055940 2018] [core:error] [pid 13642] [client 37.97.69.85:54628] AH00124: Request exceeded the limit of 10 internal redirects
due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:51:50.406171 2018] [php7:error] [pid 13793] [client 37.97.69.85:55651] PHP Fatal error: Uncaught RuntimeException:
APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file. in /var/www/demo/public/index.php:13\nStack trace:\n#0 {main}\n thrown in /var/www/demo/public/index.php on line 13
I believe this comes from the website configuration file looping somewhere, I have seen cases online where the .htaccess and the configuration file were looping but here I do not have an .htaccess file anywhere as I deleted it.
He is my website configuration :
<VirtualHost *:80>
ServerName vps562960.ovh.net
ServerAlias vps562960.ovh.net
DocumentRoot /var/www/releases/20180710151554/public
<Directory /var/www/releases/20180710151554>
AllowOverride None
Require all granted
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/crvfakeexample.com>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/releases/20180710151554/public/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/vps562960.ovh.net_error.log
CustomLog /var/log/apache2/vps562960.ovh.net_access.log combined
# optionally set the value of the environment variables used in the application
#SetEnv APP_ENV prod
#SetEnv APP_SECRET <app-secret-id>
#SetEnv DATABASE_URL "mysql://db_user:db_pass#host:3306/db_name"
</VirtualHost>
I'm starting to lose hope on deploying that website. Has anyone faced a similar case or do any of you know what I'm doing wrong?
Thanks in advance.
Most probably the problem is that Apache server doesn't set env variables into PHP global array $_SERVER. But symfony tries to find env variables exactly in $_SERVER array. Either update public/index.php and replace all $_SERVER with $_ENV or uncomment SetEnv directives in Apache website conf.

403 Forbidden, Index of / catch 22

I'm having a really rough time on this one and have tried a ton of solutions which have worked for certain people but not for me. Firstly my set up:
Ubuntu 14.04.2
Apache 2.4.7
I'm currently migrating my site to wordpress into the folder structure /var/www/dev which is set up as a virtual host - dev.conf looks like:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
ServerAdmin ubuntu#12.345.678.90
DocumentRoot /var/www/dev
ServerName dev.mysite.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/dev/>
Options -Indexes +FollowSymLinks
AllowOverride All
#Require all granted
Order allow,deny
allow from all
</Directory>
</VirtualHost>
My problem is that when I access my home page in a browser for the first time dev.mysite.com it directs me to a 403 page:
Forbidden
You don't have permission to access / on this server.
I also have an .htaccess file in my root folder that looks like this currently:
DirectoryIndex index.php index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I followed 2 different sets of advice so far - one saying to change my config Option to:
Options +Indexes
However when i navigate to my home page it gives me the physical folder "Index of /" with a list of all my files and folders - which I don't want. So I've left it as
Options -Indexes
Another set of advice said add this to the htaccess file:
DirectoryIndex index.php index.html
I've also checked my folder permissions, all owned by my apache user admin ubuntu:ubuntu and all follow the standard wordpress folder permissions e.g. all folders are 755 all files are 644 (rough rule of thumb).
I've also tried as you can see (commented out above) using the new apache 2.4 standard
Require all granted
instead of
Order allow,deny
allow from all
I'm also restarting the server every time I make a change so nothing silly like that. What am I doing in the above config that's not letting me load my site?
Specifically my homepage goes to 403 Forbidden, any other page e.g. dev.mysite.com/features loads this error message:
User-agent: *
Disallow: /wp-admin/
EDIT:
The above issues only occur when the url is loaded initially - if I refresh the page it loads as it should.
Here's my file ownership structure - perhaps this may provide useful:
-rw-rw-r-- 1 ubuntu ubuntu 350 Sep 26 19:35 .htaccess
-rw-rw-r-- 1 ubuntu ubuntu 4951 Sep 9 13:21 wp-activate.php
drwxrwxr-x 9 ubuntu ubuntu 4096 Sep 9 13:21 wp-admin
-rw-rw-r-- 1 ubuntu ubuntu 271 Sep 9 13:21 wp-blog-header.php
-rw-rw-r-- 1 ubuntu ubuntu 5007 Sep 9 13:21 wp-comments-post.php
-rw-rw-r-- 1 ubuntu ubuntu 3130 Sep 24 10:32 wp-config.php
-rw-rw-r-- 1 ubuntu ubuntu 2764 Sep 16 17:23 wp-config-sample.php
drwxrwxr-x 6 ubuntu ubuntu 4096 Sep 24 10:46 wp-content
-rw-rw-r-- 1 ubuntu ubuntu 3286 Sep 16 17:23 wp-cron.php
drwxrwxr-x 12 ubuntu ubuntu 4096 Sep 9 13:21 wp-includes
-rw-rw-r-- 1 ubuntu ubuntu 2380 Sep 9 13:21 wp-links-opml.php
-rw-rw-r-- 1 ubuntu ubuntu 3123 Sep 9 13:21 wp-load.php
-rw-rw-r-- 1 ubuntu ubuntu 34669 Sep 16 17:23 wp-login.php
-rw-rw-r-- 1 ubuntu ubuntu 8252 Sep 9 13:21 wp-mail.php
-rw-rw-r-- 1 ubuntu ubuntu 11062 Sep 16 17:23 wp-settings.php
-rw-rw-r-- 1 ubuntu ubuntu 25124 Sep 16 17:23 wp-signup.php
-rw-rw-r-- 1 ubuntu ubuntu 4035 Sep 9 13:21 wp-trackback.php
-rw-rw-r-- 1 ubuntu ubuntu 3055 Sep 16 17:23 xmlrpc.php
Forbidden 403 simply means that there is some problem with permissions. When server is trying to access the requested resource then it is being restricted due to permission issues, so those who were advising on modifying Indexes weren't even close because Indexes option is to control the directory listing. Below is excerpt about Indexes option from Apache
If a URL which maps to a directory is requested and there is no
DirectoryIndex (e.g., index.html) in that directory, then
mod_autoindex will return a formatted listing of the directory.
Clearly root cause of your issue is "permissions".
Now, for the solution part - since I don't know your all the content of your .htaccess and dev.conf, so below your be my step by step approach:
Try below code snippet. I am trying to disable your .htaccess files effect and see if that's root cause. If it works then you to review all the content of your .htaccess for possible issue.
<Directory /var/www/dev/>
Options -Indexes +FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
Try below code snippet. Default Apache access for Directory is Allow from All, so I am removing it and let default take effect and no ordering .. Anyways you were also trying same thing ..
<Directory /var/www/dev/>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
On a side note, I would suggest that first try to do chmod 777 for your web app directories and files, because in most cases permission issue is because of UNIX permissions and not Apache permissions.
Followup edit:
For further debugging we will need server error info, can you enable maximum debugging and get the content from error.log and access.log (if HTTPS access then from ssl log). Reference
Also, could you please provide context of DirectoryIndex directive and URL you are using.
All odds are that you have permission issue, may be because of Apache or UNIX.
So, lets first comprehensively rule out UNIX permissions issue, so momentarily try out chmod 777 for your web app resource, if it works we know it is UNIX permission issue and we will see what to do next.
I am getting skeptical about RewriteBase / and RewriteRule . /index.php [L] in your .htaccess file .
Give a try to RewriteBase /var/www/dev or whatever you think could be more relevant but NOT /
Also, try to play around with RewriteRule, so instead try absolute path of index.php, so use RewriteRule . /var/www/dev/<<XYZ>>/index.php
Give a try using exact below, if you don't have mod_cgi module included then you may need to.
<Directory "/home/domain/www">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Final solution:
For those who are looking for solution - once OP recursively granted permission using chmod -R www:data, he could solve this issue. So, to conclude - this issue was not because of Apache configuration but because of UNIX permissions. Read OP's comments below for more details.

How to write .htaccess rewrite rule

I installed a online website onto my ubuntu machine for development purposes.
Everything is working except for one section of the site. When I point the browser to http://localhost.000-wordpress.co/app I get the below error in my apache2 error log:
[Fri Jan 17 16:57:03 2014] [error] [client 127.0.0.1] File does not exist: /var/www/app, referer: http://localhost.000-wordpress/
The server is looking for the app folder in the wrong location on my file system. So I have created a .htaccess file but I don't know how to write a rewrite rule for this.
How should I code a rewrite rule to tell the server to go to /home/ross/public_html/000-wordpress/public/app instead of /var/www/app?
This is my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Update
After following Covner's advice I updated my apache2.conf file with:
Alias /app /home/ross/public_html/000-wordpress/public/app
<Directory /home/ross/public_html/000-wordpress/public/app>
Order deny,allow
</Directory>
But this has thrown back two different errors:
[Sat Jan 18 23:35:55 2014] [error] [client 127.0.0.1] PHP Warning: require_once(/home/ross/public_html/000-wordpress/public/app/../vendors/yii/framework/yii.php): failed to open stream: No such file or directory in /home/ross/public_html/000-wordpress/public/app/index.php on line 12, referer: http://localhost.000-wordpress/
[Sat Jan 18 23:35:55 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/home/ross/public_html/000-wordpress/public/app/../vendors/yii/framework/yii.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ross/public_html/000-wordpress/public/app/index.php on line 12, referer: http://localhost.000-wordpress/
You don't want to do anything in htaccess, just use the normal configuration file (they're all created equal)
Alias /app /home/ross/public_html/000-wordpress/public/app
<Directory /home/ross/public_html/000-wordpress/public/app>
Order deny,allow
</Directory>

Resources