Last active
October 10, 2020 07:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/etc/nginx/sites-available
and link to it from/etc/nginx/site-enabled
. (You also have to update conf/server.xml file in order to tell the Tomcat about the Nginx. Refer to this post: https://blog.servicerocket.com/adoption/blog/2014/07/3-steps-in-set-up-nginx-as-proxy-server-for-atlassian-jira)jira.service
in/lib/systemd/system/
and enable it usingsystemctl enable jira.service
in order to start the service after each reboot.