I either do not quite get how I can have Google or any Social Network to use Phantomjs to render my site or I have did something wrong.
I am using Nginx, Angularjs with Html5Mode Urls and Phantomjs.
Furthermore I use steeve/angular-seo to handle the phantomjs stuff. For this I have included the angular-seo.js and added
$scope.htmlReady();
To the end of every controller.
My Nginx config for my domain dev.example.com includes this at the end of the server tag.
if ($args ~ "_escaped_fragment_=(.*)") {
rewrite ^ /snapshot${uri};
}
location /snapshot {
proxy_pass http://dev.example.com:8888;
proxy_connect_timeout 60s;
}
My index.html includes this meta tag to let google see that it is an AJAX site.
<meta name="fragment" content="!" />
Then I run
phantomjs --disk-cache=no angular-seo-server.js 8888 http://dev.example.com
in the server console.
Now I tried to visit my site manually with http://dev.example.com/?_escaped_fragment_=/
but the site that I get back is not correctly displayed and the snapshot is also not saved to the snapshot folder.
Related
I am running a laravel project on nginx server. On a subpage I try to inject some code by SSI like this:
location /path/ {
subs_filter_types text/html;
subs_filter '</head>' '<!--#include virtual="/another/url"--></head>' i;
ssi on;
}
The injected code is not that I would expect at /another/url/. Instead the whole website /path/ is getting injected. I guess that the laravel router is still routing to the given location.
When I open my-server.com/another/url/ I get the content to inject, but when I try to inject the content at /path/, the content of my-server.com/path/ will be injected.
Is the SSI request still having the inital request location? Could it be, that laravel router is it routing wrong then?
I've just installed my Laravel application and it loads perfectly. I'm trying to make an api request from my machine to the application and from Vue.js application hosted on S3. Both attempts return 404, and in the browser console it says that I have a CORS problem. Ok, but I've installed fruitcake/cors, and this works locally. Also, I've seen that on AWS, when I try to reach /api/xxx/xxx, index.php is never reached. If I try without the /api prefix, it's reachable. Could that be a missconfiguration of nginx (I'm using the default configuration, and haven't changed anything)? Any help will be much appreaciated!
Like I was thinking, nginx is not configured properly by default. After I've added
location / {
try_files $uri $uri/ /index.php?$query_string;
}
everything worked.
I am leaving this topic if anyone else has the same problem.
I have create a Polymer based Dashboard which I want to integrate with my Laravel site. My Dashboard is working fine but I have issues with routing in Polymer.
I want my Dashboard to reside at:
http://example.com/dashboard
I have set up my Laravel route as follows:
Route::get('dashboard',function(){
return View::make('polymer.dashboard');
});
and my dashboard urls should be like:
http://example.com/dashboard/#!/feedbacks
But, I am confused about what setting to make in app.js. Current app.js:
// Sets app default base URL
app.baseUrl = '/';
if (window.location.port === '') { // if production
// Uncomment app.baseURL below and
// set app.baseURL to '/your-pathname/' if running from folder in production
//app.baseUrl = '/dashboard/';
}
Under these settings, when I navigate to http://example.com/dashboard, when Polymer finishes loading, the url changes to http://example.com/.
If you haven't told the router to not use hashbangs then navigating to /dashboard won't work, it's expecting #!. You'll need to go into app/elements/routing.html and remove the line that says hashbangs: true. You'll also need to set the baseUrl to /dashboard/. Your server will also need to always return the index.html for any URL that starts with dashboard. So if the user tries to go to example.com/dashboard/feedback it should send down the index.html page again.
After you've made the change to routing.html, go into the devtools settings and enable Disable cache (with dev tools open). Then reload the app to make sure it isn't serving a cached version of the file.
Which folder should I use to save users avatar photos in Tomcat container, and how can I show it in view?
I know that it must be outside of war file, but I cannot access images with image tag which is outside of extracted war folder. An example on uploading and showing user profile photos is appreciated.
If they're just small avatars, you could consider persisting them to your database. When you need to display them again you can fetch them from the db and write them to the response's outputstream.
Here's an example of how to do this:
http://grails.1312388.n4.nabble.com/Load-image-from-database-and-show-it-in-a-gsp-td4644393.html
Acually Tomcat aren't good in serving static file, so it's very common to put a "frontend" in front of your Java app. Usually it's Nginx server. If you aren't using Nginx, I strongly suggest to start using it, Nginx can give you up to 5x speedup.
With Nginx you can store/and server images from any directory:
server {
location ~ ^\/(css|js|images)\/.*\.(gif|jpg|jpeg|png|ico|css|js)$ {
root PATH_TO_WEBAPP;
}
location ~ ^\/avatar\/.*$ {
root PATH_TO_AVATARS;
}
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
Where:
PATH_TO_WEBAPP is where tomcat have extracted you app (/etc/tomcat/webapps/myapp)
PATH_TO_AVATARS is your directory for storing avatars (/etc/my_avatars)
http://127.0.0.1:8080 just forward all other requests to Tomcat on localhost:8080
So, you'll be able to store avatars in own directory from Grails, and serve them through Nginx. For end user it will be a url like /avatars/myavatar.png, so you can use
resource tag as usual:
<img src="${resource(dir: 'avatars', file: 'myavatar.png')}" />
I have an nginx up at the front serving as a proxy to two servers, one running Websphere Portal Server and one running Spring on a Jboss server.
I'm currently having problems with the proxying of certain requests, for instance, I have the following:
server{
listen:8080;
server_name:localhost;
location /jbossSpring/ {
proxy_pass http://177.21.1.15:9000/Spring_project/;
}
location /webspherePortal/ {
proxy_pass http://177.21.1.15:9400/Portal_project/;
}
}
Now, this does the proxy from localhost:8080/jbossSpring/ and localhost:8080/webpsherePortal/ correctly, however, the pages I get keep requesting files that are located on localhost:8080/Spring_project/ and localhost:8080/Portal_project/.
Is there anyway for me to handle these in nginx? or do I have to modify the Spring/Portal projects to get the right url? (path dependencies probably?)
You may achieve this result by using http rewrite module, documented at ngx_http_rewrite_module
To give an idea, I guess your rewrites shall look like below (I haven't validated this)
server {
...
rewrite ^/Spring_project/(.*) /jbossSpring/$1 last;
rewrite ^/Portal_project/(.*) /webspherePortal/$1 last;
...
}