# \[Solved\] Dev instance with nginx: topic preview not working

**URL:** https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738
**Category:** Development
**Created:** [August 9, 2017, 9:09pm UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738 "2017-08-09T21:09:19Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [August 9, 2017, 9:09pm UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738/1 "2017-08-09T21:09:19Z")

</div>

When clicking “New Topic” in my dev instance, I get the following errors in the console and the preview pane doesn’t work:

```plaintext
Uncaught SyntaxError: Unexpected token < markdown-it-bundle.js:1
Error: Could not find module pretty-text/engines/discourse-markdown/helpers discourse/lib/text:40 
    at missingModule (discourse-loader:134)
    at require (discourse-loader:149)
    at setup (pretty-text/engines/discourse-markdown-it:242)
    at buildOptions (pretty-text/pretty-text:100)
    at getOpts (discourse/lib/text:25)
    at cook (discourse/lib/text:30)
    at eval (discourse/lib/text:38)
    at tryCatch (ember:50180)
    at invokeCallback (ember:50195)
    at publish (ember:50163)

```

The second error then occurs each time I input a character in the text area.

I believe this problem was not occurring a few months back, but I’m not sure. I’m currently using v1.9.0.beta5 +90.

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [September 15, 2017, 12:40pm UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738/2 "2017-09-15T12:40:41Z")

</div>

Because I run my dev instance behind a nginx reverse proxy, I’ve tried the solution proposed by @mr8 in here:

[https://meta.discourse.org/t/discourse-preview-not-working/67584/36?u=jack2](https://meta.discourse.org/t/discourse-preview-not-working/67584/36)

It hasn’t solve the issue, but the error has changed. I now get:

```plaintext
GET https://127.0.0.1:3000/assets/markdown-it-bundle.js net::ERR_CONNECTION_CLOSED jquery:9245 
Error: error ember:19818 
    at unwrapErrorThrown (ember:33586)
    at errorFor (ember:33568)
    at onerrorDefault (ember:33558)
    at Object.trigger (ember:49836)
    at eval (ember:50737)
    at invokeWithOnError (ember:2197)
    at Queue.flush (ember:2256)
    at DeferredActionQueues.flush (ember:2380)
    at Backburner.end (ember:2450)
    at Backburner.run (ember:2564)
Uncaught promise: {jqXHR: {…}, textStatus: "error", errorThrown: "error"} (index):455 

```

Any idea?

(also, I’ve tried to switch my instance to “force https”, but it made no difference)

---

<div class="post-metadata">

### Author: ![mr8](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mr8](https://meta.discourse.org/u/mr8)
#### Post date: [September 15, 2017, 4:26pm UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738/3 "2017-09-15T16:26:07Z")

</div>

Have you tried disabling all your plugins to see if you still get the error?

Do you have your app.yml configured for https?

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [September 15, 2017, 10:43pm UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738/4 "2017-09-15T22:43:15Z")

</div>

Thanks @mr8.

I’ve disabled all my plugins and seen no change.  
I’m running a dev instance, so I believe there’s no `app.yml` file.

In the Chrome console, I see Discourse trying to load `http://127.0.0.1:3000/assets/markdown-it-bundle.js`. Of course, **client-side** , this url points to nothing.

This url comes from the fact that my nginx is configured like this:

```plaintext
server {
  ...
  server_name www.mydomain.org;
  ...
  location / {
    ...
    proxy_pass http://127.0.0.1:3000;
    ...
  }
}

```

i.e. `http://127.0.0.1:3000/assets/markdown-it-bundle.js` is an internal **server-side** url.

What am I missing?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [September 16, 2017, 5:34am UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738/5 "2017-09-16T05:34:48Z")

</div>

You are missing the other proxy directives. You need all of these:

```plaintext
		# proxy_pass .....;
		proxy_set_header Host $http_host;
		proxy_http_version 1.1;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		#proxy_set_header Client-IP "";

```

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247):
>
> @pfaffman edited this heavily 2022.02.24. Blame me if it’s broken. If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX or HAProxy proxy in front of the Docker container. NOTE: This is for advanced admins This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working. You cannot use ./discourse-setup to set up Discourse if another server is using port 80 or 443. You will…

---

<div class="post-metadata">

### Author: ![mr8](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@mr8](https://meta.discourse.org/u/mr8)
#### Post date: [September 16, 2017, 2:28pm UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738/6 "2017-09-16T14:28:23Z")

</div>

I’ve never used the dev instance, but it looks like discourse _thinks_ your domain is `http://127.0.0.1:3000` and serving the assets with that ‘domain’.

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [September 16, 2017, 5:25pm UTC](https://meta.discourse.org/t/solved-dev-instance-with-nginx-topic-preview-not-working/67738/7 "2017-09-16T17:25:59Z")

</div>

@riking, that did it, thanks a lot. Somewhere along the line I’d commented out my `X-Forwarded-For` line, for whatever reason.  
Thanks also for your excellent link! There’re so many Discourse+nginx pages on this forum (and on the Internet), that it’s good to have a reference one.
