symfony2 http 403 error (access denied) for CSS file - css

I have a very weird situation, one of my CSS files is not able to load, I see HTTP 403 error in firebug.
My twig:
<head>
{% block head %}
<script type="text/javascript" src="/bundles/my/js/jquery.min.js"></script>
<script type="text/javascript" src="/bundles/my/js/jquery-ui.min.js</script>
<link rel="stylesheet" href="/bundles/my/css/Aristo/Aristo.css" />
<link rel="stylesheet" href="/bundles/my/css/style.css" />
{% endblock %}
</head>
My files structure:
I've run php app/console assets:install web --symlink successfully
app/console assetic:dump returns:
Dumping all dev assets.
Debug mode is on.
Note: js/jquery.min.js, js/jquery-ui.min.js and css/style.css loads fine, only Aristo/Aristo.css yells HTTP 403 error
Edit
GET http://my.local/bundles/my/css/Aristo/Aristo.css
Response message:
Response Header
HTTP/1.1 403 Forbidden
Date: Thu, 04 Jul 2013 18:28:36 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 260
Keep-Alive: timeout=5, max=97
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
Response HTML:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /bundles/my/css/Aristo/Aristo.css
on this server.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at my.local Port 80</address>
</body></html>
Can anyone advise?
Thanks

You may use asset instead of direct path to your ressources :
<link href="{{ asset('css/Aristo/Aristo.css') }}" rel="stylesheet" type="text/css" />
see: http://symfony.com/doc/current/book/templating.html#linking-to-assets
Hope it's helpful
Best regard

Related

How do I load a webcomponent across domains?

Can you not load webcomponents from other domains?
I'm getting a cors error in firefox/linux.
I added this to nginx but still can't load it:
add_header Access-Control-Allow-Origin *;
<html lang="en">
<head>
<meta charset="utf-8" />
<script type="module" src="//briskreader.com/components/feed-list.js"></script>
</head>
<body>
<feed-list topic="bitcoin"></feed-list>
</body>
</html>
Here's the error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://briskreader.com/components/feed-list.js. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Loading module from “http://briskreader.com/components/feed-list.js” was blocked because of a disallowed MIME type (“text/html”).
test.html
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://briskreader.com/components/feed-list.js. (Reason: CORS request did not succeed).
Heres the header from briskreader.com:
$ curl -I 'https://briskreader.com/components/feed-list.js'
HTTP/2 200
server: nginx/1.18.0 (Ubuntu)
date: Sun, 21 Nov 2021 06:30:51 GMT
content-type: application/javascript
content-length: 2187
expires: Sun, 21 Nov 2021 06:30:50 GMT
cache-control: no-cache
cache-control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0
access-control-allow-origin: *
accept-ranges: bytes
Web components has nothing to do with CORS. The attribute type="module" on <script> tag causes the CORS request. Unlike classic scripts, module scripts require the use of the CORS protocol for cross-origin fetching.
Next this line add_header Access-Control-Allow-Origin *; is useless on origin domain. You must set Access-Control-Allow-Origin header on briskreader.com domain. If you do not control briskreader.com, then consider using classical script. You can still use Web components with classical script.

What software produces this pattern of redirect?

I am trying to activate HTTPS on my website but something is producing a redirect from HTTPS to a subdomain. Web guy says its the server. Server guy says its the app. I checked the vhost and httpd.conf and there is no redirect that matches. The application is Wordpress but there is no instance of the subdomain existing in the database or the source code.
Please take a look at the server response. Do you recognize what software produces this pattern of response?
$ curl -i https://www.example.com
HTTP/1.1 200 OK
Date: Tue, 23 Jan 2018 17:06:20 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.1.11
Last-Modified: Tue, 13 Jun 2006 16:25:18 GMT
ETag: "9b-4161d83351780"
Accept-Ranges: bytes
Content-Length: 155
Content-Type: text/html; charset=UTF-8
<html>
<head>
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=http://somewhereelse.example.com">
<title> redirecting...
</title></head>
<body> </body>
</html>

Nginx : redirect wordpress-like URL from subdirectory to root keeping URL

I tried to look around before posting but I wasn't able to found a solution for my issue.
I used to host a blog in a domain like http://example.com/blog and I moved it to the root /
What I'd like to do is to write a rule in NGINX telling to redirect my old articles from :
http://example.com/blog/my-dope-article
to
http://example.com/my-dope-article
Is there anyway to do that?
Thanks !
I tried this :
rewrite ^/blog/(.*) http://$server_name/$1 permanent;
But it doesn't work because http://example.com/blog/my-dope-article still got rewritten to http://example.com/blog/my-dope-article where I want to delete "/blog" part from the new URL.. :(
Have you looked at the redirects with curl or other tools to examine what exactly happens?
If you're running wordpress on / instead of /blog/ now but haven't yet changed the home- and siteurl-options, WP will create a redirect to the URL it thinks it is running at.
When you look at the headers (e.g. with curl -I http://example.com/ or by using the developer tools in your browser), you'll usually spot differences between redirects caused by nginx and redirects caused by whatever is behind nginx.
For example, a redirect by nginx itself might look like this:
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 03 Oct 2017 18:37:06 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://www.example.org/
While a redirect from apache/php/WP behind nginx might look like this
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 03 Oct 2017 18:39:44 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: https://www.example.org/
Vary: Accept-Encoding
Content-Length: 339
Notice the moved Content-Length header, added Vary header and different Content-Type.
And, of course, you can look at the body they send with redirects as well (e.g. curl -v https://www.example.org/).
Example for nginx:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
apache/WP
<!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>
<hr>
<address>Apache/2.2.16 (Debian) Server at example.org Port 80</address>
</body></html>
Yes I tried to CURL to see what happened. In the end, I found what I've done wrong: it was the syntax..
So I just put : rewrite ^/blog(.*) /$1 last; at the server directive in my nginx conf file and voilà

How to generate an HTTP POST request using Telnet?

Does anyone know how to add HTTP body parameters into a request? I've tried something like...
telnet xxxx.com 80
Trying 128.x.xxx.45...
Connected to xxxx.com.
Escape character is '^]'.
POST /webapps/methods/check-post HTTP/1.1
Host: xxxx.com
Content-Type: application/json; charset=utf-8
{"id":"myid","color":"blue"}
But I got a '400 bad request' response
HTTP/1.1 400 Bad Request
Date: Thu, 31 Aug 2017 13:54:32 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 311
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at xxxx.com Port 80</address>
</body></html>
Connection closed by foreign host.
Can anyone help me to set up a correct HTTP post request with parameters, using Telnet?
Just add another empty line between the HTTP request header and HTTP request body.The parameter should be something like: key1=value1&key2=value2

Two similar projects: one finds the CSS, other does not

I have created two Netbeans projects and both have the same configuration in web.xml:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Both have the following directory structure for the css file:
<Root>\src\main\webapp\resources\css\styles.css
In a facelets template, in the <h:head> section both have
<h:outputStylesheet name="styles.css" library="css" />
If I unzip their respective .war files, both have
<root>\resources\css\styles.css
When I launch these web apps and look at the web page thru firebug both use:
<root>javax.faces.resource/styles.css.xhtml
Now the BUT: one finds the css file and one does not. What am I missing here?
Update: As per the comments, I have checked the Net tab of Firebug of the project where the CSS fails. The CSS request/response is inside HTML tab instead of CSS tab and the response Header has Content-Type: text/html; and the response body is the entire web page rather than just the CSS like it is in the working project!
Request headers:
Host: mike-
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept: text/css,*/*;q=0.1
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Referer: http://mike-6:8080/root/
Cookie: JSESSIONID=fa60fb0becd860721422cad79e09
Response headers:
X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.1 Java/Sun Microsystems Inc./1.6), JSF/2.0
Server: GlassFish Server Open Source Edition 3.1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Wed, 31 Dec 1969 18:00:00 CST
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 19 Sep 2011 03:06:22 GMT
Response body:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/MyBills/javax.faces.resource/themes/sam/theme.css.xhtml?ln=primefaces&amp;v=3.0.M2" />
<link type="text/css" rel="stylesheet" href="/MyBills/javax.faces.resource/styles.css.xhtml?ln=css" />
</head>
<body>
/* body is entire web page */
</body>
</html>

Resources