Skip to content

Commit

Permalink
Update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Sep 21, 2023
1 parent 9a8deb2 commit f101cd3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 72 deletions.
81 changes: 33 additions & 48 deletions images/web/config/lighttpd.conf
Original file line number Diff line number Diff line change
@@ -1,55 +1,50 @@
# default document-root
server.document-root = "/var/www/cgimap/"
server.document-root = "/openstreetmap/cgimap/"

# TCP port
server.port = 81

setenv.add-response-header = (
"Access-Control-Allow-Origin" => "*",
"Access-Control-Allow-Methods" => "GET, POST, OPTIONS",
"Access-Control-Allow-Headers" => "origin, x-requested-with, content-type"
)

setenv.add-response-header += (
"Access-Control-Max-Age" => "86400" # 24 hours
)

server.reject-expect-100-with-417 = "disable"

# selecting modules
server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi", "mod_proxy", "mod_alias", "mod_openssl")
server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi", "mod_proxy", "mod_alias", "mod_setenv")

# accesslog.filename = "/dev/stdout"
# server.errorlog = "/dev/stderr"

# handling unknown routes
server.error-handler-404 = "/dispatch.map"

# server.modules += ( "mod_setenv" )

# $HTTP["url"] =~ "^/api/" {
# setenv.add-response-header = (
# "Access-Control-Allow-Origin" => "*",
# "Access-Control-Allow-Methods" => "GET, POST, OPTIONS",
# "Access-Control-Allow-Headers" => "origin, x-requested-with, content-type",
# "Access-Control-Max-Age" => "86400"
# )
# }

# include, relative to dirname of main config file
#include "mime.types.conf"

# read configuration from output of a command
#include_shell "/usr/local/bin/confmimetype /etc/mime.types"
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)

$HTTP["request-method"] != "OPTIONS" {
# Your existing redirect condition and rule here, for example:
$HTTP["scheme"] == "http" {
url.redirect = (".*" => "https://%0$0")
}
# Handle CORS Preflight Requests
$HTTP["request-method"] == "OPTIONS" {
setenv.add-response-header = (
"Access-Control-Allow-Origin" => "*",
"Access-Control-Allow-Methods" => "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers" => "origin, x-requested-with, content-type",
"Access-Control-Allow-Credentials" => "true",
"Access-Control-Max-Age" => "86400"
)
server.modules += ( "mod_setenv" )
url.access-deny = ("")
}

server.modules += ( "mod_setenv" )

$HTTP["url"] =~ "^/api/0\.6/map" {
setenv.add-response-header = (
"Access-Control-Allow-Origin" => "*",
"Access-Control-Allow-Methods" => "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers" => "origin, x-requested-with, content-type",
"Access-Control-Allow-Credentials" => "true",
"Access-Control-Max-Age" => "86400"
)
}

debug.log-request-handling = "enable"
Expand Down Expand Up @@ -83,26 +78,16 @@ $HTTP["request-method"] == "PUT" {
)
}

$HTTP["url"] =~ "^/(?!(dispatch\.map))" {
proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "80" ) ) )
}
# $HTTP["url"] =~ "^/(?!(dispatch\.map))" {
# proxy.server = ( "" => ( ( "host" => "http://127.0.0.1", "port" => "80" ) ) )
# }

fastcgi.debug = 1

fastcgi.server = ( ".map" =>
(( "socket" => "/tmp/map-fastcgi.socket",
"bin-path" => "/usr/local/bin/openstreetmap-cgimap",
"docroot" => "/",
"min-procs" => 1,
"max-procs" => 1,
(( "host" => "127.0.0.1",
"port" => 8000,
"check-local" => "disable",
"bin-environment" => (
"CGIMAP_HOST" => env.POSTGRES_HOST,
"CGIMAP_DBNAME" => env.POSTGRES_DB,
"CGIMAP_LOGFILE" => "/var/www/cgimap/log",
"CGIMAP_USERNAME" => env.POSTGRES_USER,
"CGIMAP_PASSWORD" => env.POSTGRES_PASSWORD
)
))
)

Expand Down
38 changes: 15 additions & 23 deletions images/web/config/production.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,38 @@
DocumentRoot /var/www/public
PassengerRuby /usr/bin/ruby
RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


# Handle OPTIONS requests with a 200 OK only for staging.openhistoricalmap.org
# RewriteCond %{HTTP_HOST} =tasks-staging.openhistoricalmap.org
# RewriteCond %{REQUEST_METHOD} OPTIONS
# RewriteRule ^.*$ "-" [R=200,L]
# Development mode in case domain is localhost

# # Skip redirect for other methods
# RewriteCond %{REQUEST_METHOD} !OPTIONS
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# ======Redirect to HTTPS
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !=127.0.0.1
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# # Avoid redirect staging sites
# RewriteCond %{HTTP_HOST} !=localhost
# RewriteCond %{HTTP_HOST} !=127.0.0.1
# RewriteCond %{HTTP_HOST} !=staging.openhistoricalmap.org
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# ======Redirect to wwww openhistoricalmap.org
RewriteCond %{HTTP_HOST} =openhistoricalmap.org
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# <Location />
# CGIPassAuth On
# </Location>

# ======Redirect trafict to CGIMAP====
# Rules to redirect to port 81
RewriteCond %{HTTP_HOST} =staging.openhistoricalmap.org
RewriteCond %{REQUEST_URI} ^/api/0\.6/map
RewriteRule ^.*$ http://127.0.0.1:81%{REQUEST_URI} [P,L]
# Existing rewrites
RewriteRule ^0\.6/map$ - [L,H=fcgi:127.0.0.1:81]
RewriteRule ^0\.6/(nodes|ways|relations)$ - [L,H=fcgi:127.0.0.1:81]
RewriteRule ^0\.6/(way|relation)/([^/]+)/full$ - [L,H=fcgi:127.0.0.1:81]

# If no match found, fall through to port 80
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
RewriteRule ^0\.6/(node|way|relation)/([^/]+)$ - [L,H=fcgi:127.0.0.1:80]

# Relax Apache security settings
<Directory /var/www/public>
AllowOverride None
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
</VirtualHost>
9 changes: 8 additions & 1 deletion images/web/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ while "$flag" = true; do
bundle exec rails db:migrate

# Start lighttpd and cgimap
/usr/local/bin/openstreetmap-cgimap \
--port=8000 \
--instances=30 \
--dbname=$POSTGRES_DB \
--host=$POSTGRES_HOST \
--username=$POSTGRES_USER \
--password=$POSTGRES_PASSWORD \
--logfile log/cgimap.log &
/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf

# Start the delayed jobs queue worker and Start the app
bundle exec rake jobs:work &
apachectl -k start -DFOREGROUND
Expand Down

0 comments on commit f101cd3

Please sign in to comment.