runbot/runbot/templates/nginx.xml
Xavier-Do e0795ffaea [IMP] runbot: customizable build access
This reverts commit and fixes some issues.
2023-08-07 15:07:30 +02:00

93 lines
2.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="runbot.nginx_config">
pid <t t-esc="nginx_dir"/>/nginx.pid;
error_log <t t-esc="nginx_dir"/>/error.log;
worker_processes 1;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
server_names_hash_max_size 512;
server_names_hash_bucket_size 256;
client_max_body_size 64M;
index index.html;
log_format full '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time';
access_log <t t-esc="nginx_dir"/>/access.log full;
error_log <t t-esc="nginx_dir"/>/error.log;
client_body_temp_path <t t-esc="nginx_dir"/>;
fastcgi_temp_path <t t-esc="nginx_dir"/>;
autoindex on;
gzip on;
gzip_types text/css text/plain application/xml application/json application/javascript;
map $http_x_forwarded_proto $real_scheme {
default $http_x_forwarded_proto;
'' $scheme;
}
proxy_temp_path <t t-esc="nginx_dir"/>;
proxy_read_timeout 600;
proxy_connect_timeout 600;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $real_scheme;
proxy_set_header Host $host;
server {
listen 8080 default;
location /runbot/static/ {
alias <t t-esc="runbot_static"/>;
autoindex off;
return 404;
location /runbot/static/src { }
location ~ /runbot/static/build/[^/]+/(logs|tests|coverage)/ {
autoindex on;
add_header 'Access-Control-Allow-Origin' '<t t-esc="base_url"/>';
}
}
}
<t id="root_anchor"/>
<t t-foreach="builds" t-as="build">
<t id="server_build_anchor"/>
server {
listen 8080;
server_name ~^<t t-out="re_escape(build.dest)"/>(-[a-z0-9_]+)?-<t t-esc="build._get_run_token()[0]"/>(-[a-z0-9_]+)\.<t t-esc="re_escape(build.host)"/>$;
<t id="build_anchor_authenticated"/>
location / {
<t id="build_anchor_authenticated_side_effect"/>
return 307 http://<t t-out="build.dest"/>$1.<t t-esc="build.host"/>;
}
}
server {
listen 8080;
server_name ~^<t t-out="re_escape(build.dest)"/>(-[a-z0-9_]+)?\.<t t-esc="re_escape(build.host)"/>$;
<t id="build_anchor"/>
location / { proxy_pass http://127.0.0.1:<t t-esc="build.port"/>; }
location /longpolling { proxy_pass http://127.0.0.1:<t t-esc="build.port + 1"/>; }
location /websocket {
proxy_pass http://127.0.0.1:<t t-esc="build.port + 1"/>;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $real_scheme;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
</t>
server {
listen 8080;
server_name ~.+\.<t t-out="re_escape(host_name)"/>$;
location / { return 404; }
}
}
</template>
</data>
</odoo>