Add option for using Real-IP
This commit is contained in:
parent
9ac016c3b5
commit
2b0135697b
@ -29,6 +29,7 @@ Command-line options
|
|||||||
- ```-filecontentsecuritypolicy "..."``` -- Content-Security-Policy header for files (default is "default-src 'none'; img-src 'self'; object-src 'self'; media-src 'self'; sandbox; referrer none;"")
|
- ```-filecontentsecuritypolicy "..."``` -- Content-Security-Policy header for files (default is "default-src 'none'; img-src 'self'; object-src 'self'; media-src 'self'; sandbox; referrer none;"")
|
||||||
- ```-xframeoptions "..." ``` -- X-Frame-Options header (default is "SAMEORIGIN")
|
- ```-xframeoptions "..." ``` -- X-Frame-Options header (default is "SAMEORIGIN")
|
||||||
- ```-remoteuploads``` -- (optionally) enable remote uploads (/upload?url=https://...)
|
- ```-remoteuploads``` -- (optionally) enable remote uploads (/upload?url=https://...)
|
||||||
|
- ```-realip``` -- (optionally) let linx-server know you (nginx, etc) are providing the X-Real-IP and/or X-Forwarded-For headers.
|
||||||
- ```-fastcgi``` -- (optionally) serve through fastcgi
|
- ```-fastcgi``` -- (optionally) serve through fastcgi
|
||||||
- ```-nologs``` -- (optionally) disable request logs in stdout
|
- ```-nologs``` -- (optionally) disable request logs in stdout
|
||||||
|
|
||||||
@ -48,8 +49,6 @@ server {
|
|||||||
|
|
||||||
client_max_body_size 4096M;
|
client_max_body_size 4096M;
|
||||||
location / {
|
location / {
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
fastcgi_pass 127.0.0.1:8080;
|
fastcgi_pass 127.0.0.1:8080;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ var Config struct {
|
|||||||
fileContentSecurityPolicy string
|
fileContentSecurityPolicy string
|
||||||
xFrameOptions string
|
xFrameOptions string
|
||||||
maxSize int64
|
maxSize int64
|
||||||
|
realIp bool
|
||||||
noLogs bool
|
noLogs bool
|
||||||
allowHotlink bool
|
allowHotlink bool
|
||||||
fastcgi bool
|
fastcgi bool
|
||||||
@ -48,7 +49,7 @@ func setup() *web.Mux {
|
|||||||
// middleware
|
// middleware
|
||||||
mux.Use(middleware.RequestID)
|
mux.Use(middleware.RequestID)
|
||||||
|
|
||||||
if Config.fastcgi {
|
if Config.realIp {
|
||||||
mux.Use(middleware.RealIP)
|
mux.Use(middleware.RealIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +153,8 @@ func main() {
|
|||||||
"path to ssl certificate (for https)")
|
"path to ssl certificate (for https)")
|
||||||
flag.StringVar(&Config.keyFile, "keyfile", "",
|
flag.StringVar(&Config.keyFile, "keyfile", "",
|
||||||
"path to ssl key (for https)")
|
"path to ssl key (for https)")
|
||||||
|
flag.BoolVar(&Config.realIp, "realip", false,
|
||||||
|
"use X-Real-IP/X-Forwarded-For headers as original host")
|
||||||
flag.BoolVar(&Config.fastcgi, "fastcgi", false,
|
flag.BoolVar(&Config.fastcgi, "fastcgi", false,
|
||||||
"serve through fastcgi")
|
"serve through fastcgi")
|
||||||
flag.BoolVar(&Config.remoteUploads, "remoteuploads", false,
|
flag.BoolVar(&Config.remoteUploads, "remoteuploads", false,
|
||||||
|
Loading…
Reference in New Issue
Block a user