Skip to content

Instantly share code, notes, and snippets.

@oschaaf
Created July 12, 2016 15:02
Show Gist options
  • Save oschaaf/ed7484a2dd6bd278ad549ddbcf351ed8 to your computer and use it in GitHub Desktop.
Save oschaaf/ed7484a2dd6bd278ad549ddbcf351ed8 to your computer and use it in GitHub Desktop.
absolute path rewriting
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
<link rel="stylesheet" type="text/css" href="test.css"/>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
worker_processes 1;
master_process off;
daemon off;
events {
worker_connections 1024;
}
error_log logs/error.log debug;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
pagespeed on;
pagespeed FileCachePath /tmp/pscdn;
server {
listen 8050;
server_name localhost:8050;
pagespeed MapOriginDomain 127.0.0.1:8050 localhost:8050/abckey 127.0.0.1:8050;
pagespeed ShardDomain 127.0.0.1:8050 localhost:8050/abckey;
#pagespeed MapRewriteDomain localhost:8050/abckey 127.0.0.1:8050;
pagespeed EnableFilters rewrite_domains;
#pagespeed DisableFilters inline_css;
pagespeed RewriteDeadlinePerFlushMs 1000;
pagespeed PreserveUrlRelativity off;
}
}
body {
background-image: url("/test1.jpg");
}
/*
div {
background-image: url("test2.jpg");
}*/
@oschaaf
Copy link
Author

oschaaf commented Jul 12, 2016

@oschaaf
Copy link
Author

oschaaf commented Jul 12, 2016

example output:

oschaaf@ubuntu:~/code/google/nps-testbuild-flushing⟫ curl 127.0.0.1:8050 http://localhost:8050/abckey/A.test.css.pagespeed.cf.8iK-ILAU7G.css
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>body{width:35em;margin:0 auto;font-family:Tahoma,Verdana,Arial,sans-serif}</style>
<style>body{background-image:url(http://localhost:8050/abckey/test1.jpg.pagespeed.ce.C__ndPEfe3.jpg)}</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
body{background-image:url(http://localhost:8050/test1.jpg.pagespeed.ce.C__ndPEfe3.jpg)}

@oschaaf
Copy link
Author

oschaaf commented Jul 12, 2016

-edit-:

The optimized css looks like:

body{background-image:url(http://localhost:8050/test1.jpg.pagespeed.ce.C__ndPEfe3.jpg)}

I think it should have looked like:

body{background-image:url(http://localhost:8050/abckey/test1.jpg.pagespeed.ce.C__ndPEfe3.jpg)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment