Skip to content

Instantly share code, notes, and snippets.

@xei
Last active October 10, 2020 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xei/32a1bde58e0aaa416e2fd787d71051f9 to your computer and use it in GitHub Desktop.
Save xei/32a1bde58e0aaa416e2fd787d71051f9 to your computer and use it in GitHub Desktop.
Nginx server block (virtual host) as a reverse proxy (+ cache) to Atlassian Jira + systemd unit file to manage Jira service.
proxy_cache_path /var/run/nginx-cache levels=1:2 keys_zone=nginx-cache:50m max_size=512m inactive=1440m;
proxy_temp_path /var/run/nginx-cache/tmp;
server {
listen 80;
listen [::]:80;
server_name jira.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name jira.inpinapp.com;
# Setup 'https'
include snippets/ssl-cert.conf;
include snippets/ssl-params.conf;
# Using 'gzip' and 'https' together may causes some vulnerabilities.
# gzip off;
# Prevent uploading huge files
client_max_body_size 10M;
access_log /var/log/nginx/jira.example.com.access.log;
error_log /var/log/nginx/jira.example.com.error.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8080;
set $do_not_cache 0;
if ($request_uri ~* ^(/secure/admin|/plugins|/secure/project)) {
set $do_not_cache 1;
}
proxy_cache nginx-cache;
proxy_cache_key "$scheme://$host$request_uri";
proxy_cache_bypass $do_not_cache;
proxy_cache_valid 1440m;
proxy_cache_min_uses 1;
}
}
[Unit]
Description=Atlassian Jira
After=network.target postgresql.service
[Service]
Type=forking
User=jira
PIDFile=/opt/atlassian/jira/work/catalina.pid
ExecStart=/opt/atlassian/jira/bin/start-jira.sh
ExecStop=/opt/atlassian/jira/bin/stop-jira.sh
[Install]
WantedBy=multi-user.target
@xei
Copy link
Author

xei commented Sep 23, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment