Deploying static website on Centos 7 using Apache - apache

i have trouble on set up home.html the main page.
When i set up virtual host on httpd.conf with options: -indexes , the main page return status 403 and index.html,
<VirtualHost *:80>
ServerAlias cninfineon.com
ServerAdmin root#localhost
DocumentRoot /var/www/website
DirectoryIndex home.html
ErrorLog /var/www/website/log/error.log
CustomLog /var/www/website/log/access.log combined
Options -Indexes
</VirtualHost>
<Directory "/var/www/website">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Include conf.d/autoindex.conf
Result:
HTTP/1.1 403 Forbidden
Date: Fri, 27 Jan 2023 09:52:55 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips
Last-Modified: Thu, 16 Oct 2014 13:20:58 GMT
ETag: "1321-5058a1e728280"
Accept-Ranges: bytes
Content-Length: 4897
Content-Type: text/html; charset=UTF-8
however, i set up with options: indexes FollowSymLinks, the main page return status 200 and index of file directory.
File Structure:
/var/www/website/
home.html, file contain photo, file with log
How should i to set home.html as the main page or solve 403 status code when i set as disable autoindex?

You can set home.html on DirectoryIndex of /etc/httpd/conf/httpd.conf.
<IfModule dir_module>
DirectoryIndex index.html index.php home.html,
</IfModule>
And then run:
sudo systemctl restart httpd.service

Related

Does httpd 2.4 support PUT and GET?

I've installed httpd-2.4.6-89.el7.centos.x86_64 on a CentOS 7 box and configured a webserver however I cannot get http 'PUT/POST' or 'GET' working
Below mentioned is my configuration
[root#centos-007 httpd]# cat /etc/httpd/conf.d/centos-007.conf
<VirtualHost *:80>
ServerName centos-007.gg.com
DocumentRoot "/abc/xyz"
DirectoryIndex index.html
<Location />
Require all granted
Options +Indexes
</Location>
Alias /avaya "/abc/xyz"
<Directory "/abc/xyz">
Require all granted
Dav On
<LimitExcept GET POST OPTIONS>
</LimitExcept>
Options FollowSymLinks Indexes MultiViews
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName centos-007
DocumentRoot /var/www/centos-007/pub_html
<Directory /var/www/centos-007/pub_html>
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
</VirtualHost>
The strange part is when I run a curl command to upload a file I get the below however the webpage does't show the uploaded file
* About to connect() to centos-007.gg.com port 80 (#0)
* Trying 10.170.110.100...
* Connected to centos-007.gg.com (10.170.110.100) port 80 (#0)
> PUT /avaya HTTP/1.1
> User-Agent: curl/7.29.0
> Host: centos-007.gg.com
> Accept: */*
> Content-Length: 824
> Expect: 100-continue
>
< HTTP/1.1 301 Moved Permanently
< Date: Tue, 18 Jun 2019 13:25:54 GMT
< Server: Apache/2.4.6 (CentOS)
< Location: http://centos-007.wsgc.com/xyx
< Content-Length: 245
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
</body></html>
* Closing connection 0
I could get this work using the underlying
DavLockDB /var/www/html/DavLock
<VirtualHost *:80>
ServerName centos-007.gg.com
DocumentRoot /abc/xyz
<Location />
Require all granted
Options +Indexes
</Location>
ErrorLog /var/log/httpd/error.log
CustomLog /var/log/httpd/access.log combined
Alias /xyz /abc/xyz
<Directory /abc/xyz>
Require all granted
DAV On
AuthType Basic
Require valid-user
</Directory>
</VirtualHost>

Gitlab ce on ubuntu 16.04 with letsencrypt on subdomain

I installed gitlab-ce on my v-server running Ubuntu 16.04 with apache as webserver. The installation of gitlab under git.example.com worked and I was able to setup my user via http.
I'm running my example.com website, a nextcloud instance under cloud.example.com and gitlab under git.example.com on this server and I decided to use letsencrypt.
The installation of letsencrypt for example.com and cloud.example.com works fine. I used the Gitlab Recipes for configuration, but it doesn't work properly. When I try to access gitlab under http://git.example.com the redirection to https://git.example.com does work but the https part redirects me to http://example.com and I have no idea why.
This is the server response
Request URL:https://git.example.com/
Request Method:GET
Status Code:302 Found
Remote Address:*:443
Referrer Policy:no-referrer-when-downgrade
HTTP/1.1 302 Found
Date: Sat, 03 Mar 2018 10:36:24 GMT
Server: Apache/2.4.18 (Ubuntu)
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
Location: http://example.com
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Request-Id: bdfffb7e-1c89-4308-be13-5c35a64f31f3
X-Runtime: 0.010298
X-Ua-Compatible: IE=edge
X-Xss-Protection: 1; mode=block
Content-Length: 90
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
And these are my apache config files:
<VirtualHost git.example.com:80>
ServerName git.example.com
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public/
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_NAME} =git.example.com
RewriteCond %{REQUEST_URI} !^/.well-known/.*
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
</VirtualHost>
SSL
<IfModule mod_ssl.c>
<VirtualHost git.example.com:443>
SSLEngine on
SSLCipherSuite SSLv3:TLSv1:+HIGH:!SSLv2:!MD5:!MEDIUM:!LOW:!EXP:!ADH:!eNULL:!aNULL
SSLCertificateFile /etc/letsencrypt/live/git.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/git.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
ServerName git.example.com
ServerSignature Off
ProxyPreserveHost On
ProxyPass / https://localhost:8181/
ProxyPassReverse / https://git.example.com:8181/
# http://doc.gitlab.com/ce/api/projects.html#get-single-project
AllowEncodedSlashes NoDecode
<Location />
# Apache 2.2
Order allow,deny
Allow from all
# New authorization commands for apache 2.4 and up
# http://httpd.apache.org/docs/2.4/upgrading.html#access
Require all granted
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://git.example.com/
</Location>
<Directory /opt/gitlab/embedded/service/gitlab-rails/public/>
Require all granted
</Directory>
# needed for downloading attachments
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public/
RewriteEngine on
# Apache equivalent of nginx try files
RewriteCond %{DOCUMENT_ROOT}/{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.* [OR]
RewriteCond %{REQUEST_URI} !/\.well-known/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RequestHeader set Host "git.example.com"
RequestHeader set X-Forwarded-Ssl on
# RequestHeader set X-Forwarded-For %<span class="pl-s1"><span class="p1- pse">{</span>REMOTE_ADDR<span class="ps1-pse">}</span></span>e
RequestHeader set X_FORWARDED_PROTO 'https'
#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 502 /502.html
ErrorDocument 503 /503.html
# It is assumed that the log directory is in /var/log/httpd.
# For Debian distributions you might want to change this to
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
In production.log I found this
Started GET "/" for 93.200.218.17 at 2018-03-03 11:34:31 +0100
Processing by RootController#index as HTML
Redirected to http://example.com
Filter chain halted as :redirect_unlogged_user rendered or redirected
Completed 302 Found in 4ms (ActiveRecord: 0.0ms)
But searching for this didn't help me so far. I guess there's some kind of loop where apache decides to root to domain.net but I couldn't find the source of it.
If anyone has an idea where to look for the error or can see what's wrong with my configuration I'd be grateful.
Answer to
curl -v http://127.0.0.1:8181
was:
> GET / HTTP/1.1
> Host: 127.0.0.1:8181
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: no-cache
< Content-Type: text/html; charset=utf-8
< Date: Mon, 05 Mar 2018 09:58:40 GMT
< Location: http://example.com
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-Request-Id: 17cb8d7d-918f-4d72-95ca-f6262e7537b2
< X-Runtime: 0.015595
< X-Ua-Compatible: IE=edge
< X-Xss-Protection: 1; mode=block
< Content-Length: 90
<
* Connection #0 to host 127.0.0.1 left intact
Update 1
I checked what's redirecting on the Port 8181 but I only got this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gitlab-wo 312 git 3u IPv4 188680 0t0 TCP localhost:8181 (LISTEN)
So I believe that there is some configuration error in Gitlab itself
Solution I found a hint at https://serverfault.com/questions/721698/gitlab-redirects-to-other-page and that really was the problem...
The settings of gitlab itself were wrong. THe Sign-in restrictions got http://git.example.com so I had to login with the direct link git.example.com/users/sign_in and change my settings. Now it's working.
Thanks to Dusan Bajic.
Addition
What also was a problem was, that the settings for "Home page URL" was set to my main domain. I had to change that to https://git.example.com. A simple setting I just forgot

The requested URL / was not found on this server Apache Windows7

I am having issue while setting up virtual localhosts in my httpd.conf. What i write
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Users/user/Documents/dispatcher/cache"
<Directory C:/Users/user/Documents/dispatcher/cache>
<IfModule disp_apache2.c>
SetHandler dispatcher-handler
ModMimeUsePathInfo On
</IfModule>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
My apache version is 2.2.21. Error is :
[Mon Jan 25 22:46:17 2016] [error] [client 127.0.0.1] Attempt to serve directory: C:/Users/user/Documents/dispatcher/cache/

Apache Stopps Working after config update

There is a massive problem with my XAMPP apache..... Basically I have set-up virtual hosts, and I tagged the file.
So after I update the httpd.conf file it all the sudden I can not run the apache again......
I saved a copy of the file as httpd.conf.ORG and I played with the other one and I added this:
DocumentRoot "C:/xampp/htdocs"
<VirtualHost 127.0.0.1>
ServerName aam.dev
DocumentRoot"C:\xampp\projects\aam.dev"
</<VirtualHost >
<VirtualHost 127.0.0.1>
ServerName int.tech
DocumentRoot"C:\xampp\projects\int.tech"
</<VirtualHost >
<Directory "C:/xampp/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
<Directory "C:\xampp\projects\aam.dev">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
<Directory "C:\xampp\projects\int.tech">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
I also added the two domains on the windows host file but When I tried to restart the apache it isn't WORKING AT ALL>>>>> it just says
attempting to start Apache service..
And when I go to either the access log or the error log nothing out of interest, final entries are as follow:
Access.log
127.0.0.1 - - [18/Oct/2013:18:28:40 +0100] "GET /xampp/ssi.shtml HTTP/1.0" 200 6 "-" "-"
127.0.0.1 - - [18/Oct/2013:18:28:40 +0100] "GET /xampp/status.php HTTP/1.1" 200 3110 "http://int.tech/xampp/navi.php" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0"
Error.log
[Fri Oct 18 18:29:38.212991 2013] [mpm_winnt:notice] [pid 3864:tid 260] AH00364: Child: All worker threads have exited.
[Fri Oct 18 18:29:38.252994 2013] [mpm_winnt:notice] [pid 6308:tid 384] AH00430: Parent: Child process 3864 exited successfully.
From my Understanding it just stopped normally, that is when I stopped it before making any changing, but after it is not working.... Finally, when I do restart the orginal httpd file it works.
I am assuming something is wrong with my VH Config?
Thanks in advance
BTW I am running XAMP 1.8.3

HTTPS images not caching

I'm having some problems with caching images on my web app. The images are cached after refreshing, but when I reopen the browser it's not cached anymore. I'm using HTTPS, but I'm not sure it's the problem. This is the response from the server:
Response Headers
Accept-Ranges: bytes
Cache-Control: public
Connection: close
Content-Length: 3711
Content-Type: image/png
Date: Mon, 21 May 2012 14:08:46 GMT
ETag: "446b5-e7f-4c0559b8c1c9f"
Expires: Wed, 20 Jun 2012 14:08:46 GMT
Last-Modified: Fri, 18 May 2012 20:43:41 GMT
Server: Apache/2.2.22 (Amazon)
And our httpd.conf
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
ServerName [REMOVED]
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName [REMOVED]
#Force image type
AddType image/png .png
AddType image/jpeg jpeg jpg jpe
AddType font/x-woff .woff
#Cache
ExpiresActive On
ExpiresDefault A0
<FilesMatch "\.(png|jpg|jpeg|gif)$">
ExpiresDefault "access plus 1 month"
Header set Cache-Control "public"
</FilesMatch>
#Logs
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
#SSL
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile [REMOVED]
SSLCertificateKeyFile [REMOVED]
SSLCertificateChainFile [REMOVED]
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
#Proxy
DocumentRoot [REMOVED]
ProxyPreserveHost On
ProxyRequests Off
ProxyPass [REMOVED] http://localhost:8081/[REMOVED]
ProxyPassReverse [REMOVED] http://localhost:8081/[REMOVED]
ProxyPassReverseCookiePath [REMOVED] /
Alias [REMOVED] [REMOVED]
</VirtualHost>
Any clue? Thanks!
The headers are fine. Cache-Control: public and future Expires should do the job.
It seems like it's the browser's decision not to store the cache permanently (that kind of paranoia about HTTPS data is typical), and I don't think you can do anything about that.