# Merge with the reviewed live PlotDirector configuration; do not enable two vhosts # for the same host. Preserve existing maintenance, verification and ACME locations. map $http_upgrade $plotdirector_website_upgrade { default upgrade; '' close; } map $cookie_PlotDirectorWebsiteAntiforgery $plotdirector_public_antiforgery { default "PlotDirectorWebsiteAntiforgery=$cookie_PlotDirectorWebsiteAntiforgery;"; "" ""; } map $cookie_PlotDirectorWebsiteSolverResult $plotdirector_public_solver { default "PlotDirectorWebsiteSolverResult=$cookie_PlotDirectorWebsiteSolverResult;"; "" ""; } server { listen 80; listen [::]:80; server_name plotdirector.com www.plotdirector.com; location ^~ /.well-known/acme-challenge/ { root /srv/plotdirector/acme; default_type text/plain; } location / { return 301 https://plotdirector.com$request_uri; } } server { listen 443 ssl; listen [::]:443 ssl; server_name www.plotdirector.com; ssl_certificate /etc/letsencrypt/live/plotdirector.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/plotdirector.com/privkey.pem; return 301 https://plotdirector.com$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name plotdirector.com; ssl_certificate /etc/letsencrypt/live/plotdirector.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/plotdirector.com/privkey.pem; access_log /var/log/nginx/plotdirector-website-access.log; error_log /var/log/nginx/plotdirector-website-error.log; client_max_body_size 100m; gzip on; gzip_types text/plain text/css application/javascript application/json application/xml image/svg+xml; location ~* ^/_deployment(?:/|$) { return 404; } # Request bodies, bearer credentials and websocket upgrades must reach the app. # Browser redirects are insufficient for these legacy integration clients. # Keep taskpane scripts/styles/icons on the same legacy origin during client updates. location ~* ^/(api|hubs|native-companion|word-companion|uploads|css/(?:word-companion|notifications)\.css|js/(?:notifications|word-notifications|word-companion-host(?:\.min)?)\.js|android-chrome-(?:192x192|512x512)\.png|apple-touch-icon\.png)(?:/|$) { proxy_pass http://127.0.0.1:5001; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $plotdirector_website_upgrade; proxy_read_timeout 120s; add_header X-Robots-Tag "noindex, nofollow" always; } # Published help images belong to the website, even though the legacy URL # contains the former application drawer controller name. location ~* ^/HelpDrawer/(?:Image|Article)$ { proxy_pass http://127.0.0.1:5004; proxy_set_header Cookie "$plotdirector_public_antiforgery$plotdirector_public_solver"; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location ~* ^/(Acceptance|Account|Admin|Ai|AiAdministration|Analytics|Appearance|Archives|BookRecovery|Books|Chapters|CharacterAttributes|CharacterWorkspace|Characters|ContextNames|ContextNavigation|ContextRelationshipLenses|ContextTools|ContinuityExplorer|DeploymentHealth|Dynamics|Exports|FeatureRequests|FloorPlans|Geography|HelpDiagnostics|HelpDrawer|Imports|IntelligenceReview|IntentAssessment|InvestigationCompanion|LocationWorkspace|Locations|ManageAccount|ManuscriptReader|Maps|NameVerification|Names|NarrativeFocus|NativeChapterSync|NativeCompanion|NativeCompanionAuth|NativeCompanionWorkflow|NativeInstallation|NativeManuscriptCapture|NativePresence|NativeWorkspace|Onboarding|ParagraphManuscript|PlotLineWorkspace|PlotLines|PlotThreads|ProjectCollaborators|ProjectMetrics|ProjectRestorePoints|Projects|RelationshipMap|Scenarios|SceneMetrics|Scenes|SharedFocus|SpatialContext|StoryAssets|StoryBible|StoryCalendar|StoryPoint|StripeWebhook|Timeline|Toolbar|Warnings|WordCompanion|WordCompanionHost|Writer|WriterActivities|WriterAuthoring|WriterInvestigations|WriterPlanning|WriterReview|WriterWord|WriterWork|Writing|WritingActivity|WritingSolverAdmin|WritingSolverReview|WritingSolverWorkspace|admin|intelligence-review|manuscript|onboarding|InvestigationCompanion|problem-solver/workspace|writing-problems/workspace|Home|Pricing/(?:StartTrial|Checkout))(?:/|$) { # Named-location forwarding preserves method/body for legacy AJAX and API-like # controller actions. Only normal browser GET/HEAD navigation redirects. error_page 418 = @plotdirector_legacy_application; if ($request_method !~ ^(GET|HEAD)$) { return 418; } if ($http_x_requested_with = XMLHttpRequest) { return 418; } if ($http_accept ~* application/json) { return 418; } return 308 https://app.plotdirector.com$request_uri; } location @plotdirector_legacy_application { proxy_pass http://127.0.0.1:5001; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; add_header X-Robots-Tag "noindex, nofollow" always; } # Retain original public Help and solver URLs, including legacy help redirects. location / { proxy_pass http://127.0.0.1:5004; proxy_set_header Cookie "$plotdirector_public_antiforgery$plotdirector_public_solver"; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }