1

I have a home server that is accessible from outside with a static IP and port http://<homeip>:10001. This is a Lighttpd server.

I also own a website https://example.com with Apache, I've created a rewrite rule to do this:

https://example.com/nas ---> http://<homeip>:10001

.htaccess, see that I used P option so that the URL doesn't change:

RewriteEngine on
RewriteRule ^nas$ http://<homeip>:10001 [P,L]

But if I point to https://example.com/nas, I see a "Service Temporarily Unavailable" error.

The Apache server log says:

Connection refused: proxy: HTTP: attempt to connect to <homeip>:10001 (*) failed

And this is my home server configuration (/etc/lighttpd/lighttpd.conf):

server.modules = (
        "mod_indexfile",
        "mod_setenv",
        "mod_access",
        "mod_alias",
        "mod_redirect",
        "mod_accesslog",
)

accesslog.filename          = "/var/log/lighttpd/access.log"

server.document-root        = "/var/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80


# strict parsing and normalization of URL for consistency and security
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails
# (might need to explicitly set "url-path-2f-decode" = "disable"
#  if a specific application is encoding URLs inside url-path)
server.http-parseopts = (
  "header-strict"           => "enable",# default
  "host-strict"             => "enable",# default
  "host-normalize"          => "enable",# default
  "url-normalize-unreserved"=> "enable",# recommended highly
  "url-normalize-required"  => "enable",# recommended
  "url-ctrls-reject"        => "enable",# recommended
  "url-path-2f-decode"      => "enable",# recommended highly (unless breaks app)
 #"url-path-2f-reject"      => "enable",
  "url-path-dotseg-remove"  => "enable",# recommended highly (unless breaks app)
 #"url-path-dotseg-reject"  => "enable",
 #"url-query-20-plus"       => "enable",# consistency in query string
)

index-file.names            = ( "index.php", "index.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
include "/etc/lighttpd/conf-enabled/*.conf"

#server.compat-module-load   = "disable"
server.modules += (
        "mod_compress",
        "mod_dirlisting",
        "mod_staticfile",
)

$SERVER["socket"] == ":10001" {
        server.document-root        = "/var/www/myfolder"

What am I missing? Is it the right way to redirect to my static IP address without changing the URL?

1
  • Hopefully your config is cut off above. Otherwise, you have a syntax error in the config. lighttpd -f /etc/lighttpd/lighttpd.conf -tt will test and pre-flight the config, reporting any errors. Once you are sure that lighttpd is running, have you tried connecting from the server running Apache directly to <homeip>:10001 to ensure that you can reach it from the server running Apache?
    – gstrauss
    Feb 7, 2020 at 5:51

0

You must log in to answer this question.

Browse other questions tagged .