Can we add a php page to discourse?

I Have a php code and I want to add it to my discourse app and access this php file throw domain name.
for example I want to have this url:
can anyone help me?

1 Like

Put an external nginx outside of Discourse docker, set it up to server your php page, and forward rest of the requests to Discourse.

But there is a pitfall, if you put URL of that page in a forum post and someone clicks on it, Discourse will intercept it and show page does not exist error. So you have to route your users to that URL from somewhere else outside of Discourse.


I had putted nginx outside the docker yesterday.
I have a https license and I used it for my discourse site.
I want to ajax to that file in my forum.Is it ok?(I think ajax is brower’s job, not discourse and I think it is ok)

Be more specific about “to ajax to that file in my forum”.

As far as I know, the pitfall I mentioned is due to Discourse intercepts the link in post in browser. If what you planed is to have some kind of Discourse plugin work in the browser also, I have to say you may only get the answer by test it.

1 Like

I mean:
I want to ajax to
and the Javascript file is running on my discourse app.

When you say “running on my discourse app”, do yo mean in the server container or in the client browser? The discourse app consist of frontend code running in browser and backend code running in server.

Since you sad “ajax to” I’m under the impression that your code is running in browser. As mentioned earlier, the best way is to test and see if it is OK.

If you code is running on server side, it should be OK as long as your external nginx is configured correctly.

1 Like

AFAIK you can not run PHP code in Ruby. There may be some kind of gem, but if there is, I don’t know of it.
On the other hand, Discourse should be able to work with non-Discourse JSON
You would need to smooth out same origin concerns, but I don’t see any reason why it couldn’t be done.