Last active
October 23, 2019 14:38
-
-
Save makyo/1e07a1065b2366e695df8ca5bc0b54d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/html; | |
index index.html index.htm index.nginx-debian.html; | |
server_name _; | |
autoindex on; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
location /widget-embed { | |
alias /var/www/html; | |
} | |
location /widget-noembed { | |
add_header X-Frame-Options DENY; | |
alias /var/www/html; | |
} | |
location /widget-redirect-noembed { | |
return 301 $scheme://$host/widget-noembed; | |
} | |
location /widget-redirect-missing { | |
return 301 $scheme://$host/bad-wolf; | |
} | |
location /widget-redirect-noembed-reverse { | |
add_header X-Frame-Options DENY; | |
return 301 $scheme://$host/widget-embed; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func test(url string) { | |
r, err := http.Head(url) | |
fmt.Printf("res: %+v; err: %+v\n\n", r, err) | |
} | |
func main() { | |
test("http://synapse.local/widget-embed") | |
test("http://synapse.local/widget-noembed") | |
test("http://synapse.local/widget-redirect-embed") | |
test("http://synapse.local/widget-redirect-noembed") | |
test("http://synapse.local/widget-redirect-noembed-reverse") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allows embed, no DENY | |
res: &{Status:200 OK StatusCode:200 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Ranges:[bytes] Connection:[keep-alive] Content-Length:[612] Content-Type:[text/html] Date:[Wed, 23 Oct 2019 14:35:23 GMT] Etag:["5db05eaf-264"] Last-Modified:[Wed, 23 Oct 2019 14:07:43 GMT] Server:[nginx/1.15.9 (Ubuntu)]] Body:{} ContentLength:612 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc0000c8100 TLS:<nil>}; err: <nil> | |
// Does not allow embed, has DENY | |
res: &{Status:200 OK StatusCode:200 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Ranges:[bytes] Connection:[keep-alive] Content-Length:[612] Content-Type:[text/html] Date:[Wed, 23 Oct 2019 14:35:23 GMT] Etag:["5db05eaf-264"] Last-Modified:[Wed, 23 Oct 2019 14:07:43 GMT] Server:[nginx/1.15.9 (Ubuntu)] X-Frame-Options:[DENY]] Body:{} ContentLength:612 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc000114100 TLS:<nil>}; err: <nil> | |
// Allows embed, redirects to allow embed, allows embed, no DENY | |
res: &{Status:404 Not Found StatusCode:404 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Connection:[keep-alive] Content-Length:[162] Content-Type:[text/html] Date:[Wed, 23 Oct 2019 14:35:23 GMT] Server:[nginx/1.15.9 (Ubuntu)]] Body:{} ContentLength:162 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc00014c000 TLS:<nil>}; err: <nil> | |
// Allows embed, redirects to disallow embed, does not allow embed, has DENY | |
res: &{Status:200 OK StatusCode:200 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Ranges:[bytes] Connection:[keep-alive] Content-Length:[612] Content-Type:[text/html] Date:[Wed, 23 Oct 2019 14:35:23 GMT] Etag:["5db05eaf-264"] Last-Modified:[Wed, 23 Oct 2019 14:07:43 GMT] Server:[nginx/1.15.9 (Ubuntu)] X-Frame-Options:[DENY]] Body:{} ContentLength:612 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc00014c100 TLS:<nil>}; err: <nil> | |
// Disallows embed, redirects to allow embed, allows embed, no DENY | |
res: &{Status:200 OK StatusCode:200 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Ranges:[bytes] Connection:[keep-alive] Content-Length:[612] Content-Type:[text/html] Date:[Wed, 23 Oct 2019 14:35:23 GMT] Etag:["5db05eaf-264"] Last-Modified:[Wed, 23 Oct 2019 14:07:43 GMT] Server:[nginx/1.15.9 (Ubuntu)]] Body:{} ContentLength:612 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc0000c8600 TLS:<nil>}; err: <nil> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment