Deploying gridsome app to apache 2 server - apache

I have a Static Site written with Gridsome that I would like to deploy to my LAMP server running Apache 2.4. Looking on line I have tried several solutions including a 200.html in the directory and adding a .htacces file in the directory with contents -
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
But site does not load correctly(no css, js) and all Product pages come back 404 Not Found. I see in console that css and js files are all coming back 404 codes.
Here are Apache logs:
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /furniture/ HTTP/1.1" 200 3894 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/css/0.styles.be923654.css HTTP/1.1" 404 490 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/js/app.f3ee1f73.js HTTP/1.1" 404 490 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/js/page--src-pages-index-vue.aca59de8.js HTTP/1.1" 404 491 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/js/app.f3ee1f73.js HTTP/1.1" 404 490 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/js/page--src-pages-index-vue.aca59de8.js HTTP/1.1" 404 490 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/static/favicon.ac8d93a.5667663fadd9573f98b6a9c36dd676aa.png HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/js/page--node-modules-gridsome-app-pages-404-vue.0ed1ba31.js HTTP/1.1" 404 490 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/js/page--src-pages-about-vue.de5a1202.js HTTP/1.1" 404 490 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:07 -0500] "GET /assets/js/page--src-templates-product-vue.05ad6ad3.js HTTP/1.1" 404 491 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
And when I try to go to one of the Product Pages -
172.16.178.62 - - [16/Jan/2020:13:24:52 -0500] "GET /products/strul-rug/ HTTP/1.1" 404 491 "http://172.16.178.9/furniture/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
172.16.178.62 - - [16/Jan/2020:13:24:52 -0500] "GET /favicon.ico HTTP/1.1" 404 490 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
Update: I see the problem. When looking at dev console network all the URI requests are:
Request URL:http://172.16.178.9/assets/css/0.styles.be923654.css
Request Method:GET
They should be
http://172.16.178.9/furniture/some/asset/to/get
How can one rectify this? thanks..

If it's just a html file, there is no reason that apache would not be able to serve it, but as you have modified .htaccess make sure that apache .conf file allows you to override to directory level htaccess files.
I mean does your server's conf allow you to oberride the htaccess? there should be a line similar to following in your main apache conf file (located by default at /etc/apache2/apache2.conf):
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
In general I am not sure why you even need htaccess file if all you are trying to serve are static HTML and CSS,JS files.

Turns out real simple. I needed to add pathPrefix property to gridsome.config.js to make build include /furniture in URI's.
// gridsome.config.js
module.exports = {
siteName: "Ecommerce & Gridsome",
pathPrefix: "/furniture",
templates: {
Product: "/products/:title" // Set route for allProduct node's
}
};

Related

Getting logged out immediately after logging into an Apache webapp (OpenClinica)

I am running an OpenClinica install on my webserver and experience the following problem on Google Chrome only:
I access the landing page
I log into the root (or any other) account
On the logged in overview, I click any link (eg. list all patients)
I get logged out and thrown back to the landing page
This happens only on Google Chrome. Here are the relevant entries from the access.log - can anyone make sense of these? I don't have any knowledge of HTTP status codes.
[03/Sep/2019:13:29:09 +0200] "POST /OpenClinica/j_spring_security_check HTTP/1.1" 302 328 "http://my-url.com/OpenClinica/pages/login/login;jsessionid=E6A0E2838AA51B1DA9F6AED47C42D5CD" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:09 +0200] "GET /OpenClinica/favicon.ico HTTP/1.1" 304 177 "http://my-url.com/OpenClinica/pages/login/login;jsessionid=E6A0E2838AA51B1DA9F6AED47C42D5CD" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:09 +0200] "GET /OpenClinica/MainMenu HTTP/1.1" 200 8269 "http://my-url.com/OpenClinica/favicon.ico" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:10 +0200] "GET /favicon.ico HTTP/1.1" 302 421 "http://my-url.com/OpenClinica/MainMenu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:10 +0200] "GET /OpenClinica/pages/login/login;jsessionid=EA92FE865CF5345428D7538D18871D99 HTTP/1.1" 200 4770 "http://my-url.com/OpenClinica/MainMenu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
Click on List all patients
[03/Sep/2019:13:29:12 +0200] "GET /OpenClinica/ListStudySubjects HTTP/1.1" 302 272 "http://my-url.com/OpenClinica/MainMenu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:12 +0200] "GET /OpenClinica/pages/login/login HTTP/1.1" 200 4770 "http://my-url.com/OpenClinica/MainMenu" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:12 +0200] "GET /favicon.ico HTTP/1.1" 302 422 "http://my-url.com/OpenClinica/pages/login/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:12 +0200] "GET /OpenClinica/pages/login/login;jsessionid=9625D469100D1871538197FE241DECCB HTTP/1.1" 200 4770 "http://my-url.com/OpenClinica/pages/login/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
[03/Sep/2019:13:29:12 +0200] "GET /OpenClinica/RssReader HTTP/1.1" 200 757 "http://my-url.com/OpenClinica/pages/login/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
Now I do have some whacky redirect rules, which I think are the root cause of the problem. They were written as a fix to a different problem - when logging in to the system, instead of regularly looking at the favicon, the browser (any browser) would attempt to OPEN the favicon.ico as a picture, leading to, depending on the browser, a 404 page or the favicon being opened as a picture full screen. Here are the redirect rules:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.my-url.com
ProxyPreserveHost On
ProxyPass /OpenClinica/favicon.ico http://localhost:8080/OpenClinica/
ProxyPassReverse /OpenClinica/favicon.ico http://localhost:8080/OpenClinica/
ProxyPass /OpenClinica/ http://localhost:8080/OpenClinica/
ProxyPassReverse /OpenClinica/ http://localhost:8080/OpenClinica/
ProxyPass / http://localhost:8080/OpenClinica/
ProxyPassReverse / http://localhost:8080/OpenClinica/
</VirtualHost>
Not used the specific application. As I see it, if you login while on / and you receive a cookie that is for /OpenClinica/ then: clicking on a relative link (that will keep you on /) would prevent the browser from re-sending the received cookie to the server.
I would replace the last 2 entries with something like:
RedirectMatch ^/$ /OpenClinica/
I did not exactly understand the issue with favicon but maybe you want to apply the same rule there.
Note: For RedirectMatch to work , mod_alias should be enabled.
Another thing: I see ProxyPreserveHost enabled. This means that OpenClinica should be aware of its external host name.
So that server is listening to port :80, but those proxy rules are all on port :8080 ... while I merely wonder why you need to configure proxy rules on localhost?
Just drop all of them and ignore the favicon issue meanwhile... the jsessionid being passed along with the URL rather hints for the server not handling the session properly, because such ID usually belongs into the request headers; putting them into the URL is the fallback option (because anyone who can see the logs can hijack these sessions, while in progress... no need for a password). With HTTPS it's not that bad, but on HTTP this is also visible in eventual proxy logs.
Honestly, I don't think this is a Chrome problem, but rather the vhost configuration and/or sessions problem.
It seems to stem from the vhost not having a DocumentRoot directive - and so it will inherit the global configuration, which seems to be one level above /OpenClinica.

add SSL to dropwizard with jetty

i have spend a lifetime while traying to configurate SSL for Dropwizard
what i do is to start the dropwizard application with java -jar command in my console
NOT : i'am working right now on windows , but i'am planning to deploy the solution on linux after .
when i start my application , all works fine :
INFO [2018-10-16 16:23:26,739] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler#24dc150c{/,null,AVAILABLE}
INFO [2018-10-16 16:23:26,759] org.eclipse.jetty.server.AbstractConnector: Started application#20231384{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
INFO [2018-10-16 16:23:26,762] org.eclipse.jetty.server.AbstractConnector: Started admin#3ba97962{HTTP/1.1,[http/1.1]}{0.0.0.0:8081}
INFO [2018-10-16 16:23:26,762] org.eclipse.jetty.server.Server: Started #3071ms
when i hit on my browser/or my android client a normal request the server show me this :
0:0:0:0:0:0:0:1 - - [16/oct./2018:16:30:25 +0000] "GET /robots.txt HTTP/1.1" 404 43 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" 69
0:0:0:0:0:0:0:1 - - [16/oct./2018:16:30:25 +0000] "GET / HTTP/1.1" 404 43 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" 69
0:0:0:0:0:0:0:1 - - [16/oct./2018:16:30:30 +0000] "GET /robots.txt HTTP/1.1" 404 242 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" 8
0:0:0:0:0:0:0:1 - - [16/oct./2018:16:30:30 +0000] "GET / HTTP/1.1" 200 553 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" 4
0:0:0:0:0:0:0:1 - - [16/oct./2018:16:30:31 +0000] "GET /favicon.ico HTTP/1.1" 404 243 "http://localhost:8081/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" 1
but i have an other client who is configurate to work with SSL ( and it's the mean client, the others is just for the test )
when i hit the same request with HTTPS , that what happen :
WARN [2018-10-16 16:32:29,216] org.eclipse.jetty.http.HttpParser: Illegal character 0x16 in state=START for buffer HeapByteBuffer#12404fb3[p=1,l=517,c=8192,r=516]={\x16<<<\x03\x01\x02\x00\x01\x00\x01\xFc\x03\x036\xD2T\xFd5\xF9\xCd...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
googing this error i get tat is an problem with my server , he is not prepared to communicat with SSL
so how i can work with SSL or configurate SSL on jetty ?
i fix this by adding the the https params under server area on the yml config file
but i got some errors on ssl handshake so i fixed by creating the keystore .

Apache returning blank page, only occasionally

I am having a problem with Apache randomly returning a blank page. It happens several times a day without any rhyme or reason. When this happens, the Apache access log indicates a 301 redirect to the same page which returns a 200 and no content, 0 bytes returned. Reloading the page works normally returning a 200 with content.
xxx.xxx.xxx.xxx - - [05/Apr/2018:09:52:43 -0400] "GET /administrator HTTP/1.1" 301 255 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/yyy.yyy.yyy.yyy Safari/537.36"
xxx.xxx.xxx.xxx - - [05/Apr/2018:09:52:43 -0400] "GET /administrator/ HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/yyy.yyy.yyy.yyy Safari/537.36"
xxx.xxx.xxx.xxx - - [05/Apr/2018:09:52:47 -0400] "GET /administrator/ HTTP/1.1" 200 1937 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/yyy.yyy.yyy.yyy Safari/537.36"
This is also a Joomla installation, but looking at the log I'm not sure how that would have any bearing. It also doesn't matter what page, it happens with random pages as well.

Apache Reverse Proxying CGI scripts

I have a web application called routers2.cgi which I am trying to proxy via an Apache 2.4 proxy server which does not work at the moment.
Direct URL to the web application server
http://lab.server.com/cgi-bin/routers2.cgi
Reverse proxy URL
https://prod.server.com/routers2
Configuration vhosts.conf from prod.server.com
# routes2.cgi
ProxyPass "/routers2" "http://lab.server.com/cgi-bin/routers2.cgi"
ProxyPassReverse "/routers2" "http://lab.server.com/cgi-bin/routers2.cgi"
ProxyPass "/rrdicons" "http://lab.server.com/routers2/rrdicons"
ProxyPassReverse "/rrdicons" "http://lab.server.com/routers2/rrdicons"
ProxyPass "/graphs" "http://lab.server.com/routers2/graphs"
ProxyPassReverse "/graphs" "http://lab.server.com/routers2/graphs"
Reverse proxy log samples
192.168.1.10 - - [13/Jun/2017:06:40:37 +0000] "GET /routers2 HTTP/1.1" 200 3481
192.168.1.10 - - [13/Jun/2017:06:40:37 +0000] "GET /rrdicons/routers2.css HTTP/1.1" 304 -
192.168.1.10 - - [13/Jun/2017:06:45:57 +0000] "GET /routers2 HTTP/1.1" 200 3481
192.168.1.10 - - [13/Jun/2017:06:45:57 +0000] "GET /rrdicons/routers2.css HTTP/1.1" 304 -
Sample URL from web application access log when accessing directly (no reverse proxy)
192.168.1.9 - - [13/Jun/2017:05:50:46 +0000] "GET /routers2/graphs/devicessystem1.cfg-10.10.1.1_13-ws-x3.png HTTP/1.1" 200 27025 "http://lab.server.com/cgi-bin/routers2.cgi?rtr=devices%2Fsystem1.cfg&bars=Cami&xgtype=w&page=graph&xgstyle=x3&xmtype=routers" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"
192.168.1.9 - - [13/Jun/2017:05:50:46 +0000] "GET /cgi-bin/routers2.cgi?rtr=devices%2Fsystem1.cfg&bars=Cami&xgtype=w&page=menub&xgstyle=x3&if=_summary_&xmtype=options HTTP/1.1" 200 12437 "http://lab.server.com/cgi-bin/routers2.cgi" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"
192.168.1.9 - - [13/Jun/2017:05:50:46 +0000] "GET /cgi-bin/routers2.cgi?rtr=devices%2Fsystem1.cfg&bars=Cami&xgtype=w&page=menu&xgstyle=x3&xmtype=routers HTTP/1.1" 200 7847 "http://lab.server.com/cgi-bin/routers2.cgi" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"
Web application log via reverse proxy
prod.server.com - - [13/Jun/2017:07:21:58 +0000] "GET /cgi-bin/routers2.cgi/ HTTP/1.1" 200 3481 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"
prod.server.com - - [13/Jun/2017:07:21:58 +0000] "GET /routers2/rrdicons/routers2.css HTTP/1.1" 304 - "https://prod.server.com/routers2/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"
Does my vhosts ProxyPass and ProxyPassReverse configuration look correct?
Do I need something extra since we are proxying a cgi script?

Can a loopback log entry represent an attack to apache webserver?

Since approximately one month I have been cumulating a lot of these entries as below list in my server in the Apache2 log file. I have spent several days trying to find out if this is really a hack in the server and how to really interpret this kind of entries. I would like to ask your help to clarify if this is an attack and, if it is, then where to search for the intruder script or file within the server. The referer changes quite frequently, but the requested resources are usually the same, mainly dumped
sql files.
127.0.0.1 - - [01/May/2017:13:05:39 -0500] "GET /sql.sql HTTP/1.1" 404 460 "e5755.com" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36"
127.0.0.1 - - [01/May/2017:13:05:43 -0500] "GET /db.zip HTTP/1.1" 404 459 "e5755.com" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36"
127.0.0.1 - - [01/May/2017:13:05:52 -0500] "GET /db.tar.gz HTTP/1.1" 404 470 "smbexperience.com" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36"