I would like to share my production nginx config here, it worked for me but maybe there is something unreasonable.
If you find something unreasonable, share your ideas with me, please
I am using JWT token for authentication, so I proxy token in my SPA cookie to Orthanc request header. Everything works well except some URL formats (still got 403), I list them in another thread.
server {
listen 80;
server_name yourdomain.com;
include conf.d/basic.conf;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name yourdomain.com;
include conf.d/basic_ssl.conf;
ssl_certificate /root/certs/yourdomain.com/bundle.crt;
ssl_certificate_key /root/certs/yourdomain.com/private.key;
access_log logs/yourdomain.com.log main;
root /root/www/yourdomain.com;
index index.html;
location / {
try_files $uri $uri/ /index.html;
log_not_found off;
}
location /pacs/ {
proxy_pass http://127.0.0.1:8042/;
include conf.d/headers.conf;
if ($request_method = “OPTIONS”) {
add_header Access-Control-Allow-Origin “*”;
add_header Access-Control-Allow-Methods “GET,POST,OPTIONS”;
add_header Access-Control-Allow-Headers “DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Accept”;
add_header Access-Control-Max-Age 1728000;
add_header Content-Type “text/plain; charset=utf-8”;
add_header Content-Length 0;
return 204;
}
add_header Access-Control-Allow-Origin “*”;
add_header Access-Control-Allow-Methods “GET,POST,OPTIONS”;
add_header Access-Control-Allow-Headers “DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Accept”;
add_header Access-Control-Expose-Headers “Content-Length,Content-Range”;
proxy_http_version 1.1;
proxy_redirect off;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_connect_timeout 100;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Authorization “Bearer $cookie_token”;
proxy_cache_bypass $http_upgrade;
rewrite /pacs(.*) $1 break;
}
}
在 2019年7月1日星期一 UTC+8上午3:50:41,Ludwig Moreno写道: