Subfolder nginx help


(Quenten) #1

Hi,
I have followed the procedure and it seems it’s working fine.
My problem is the following:
I have a symfony2 app runing on my main domain. Using Nginx, I’m setting a root folder for the app.
Then I’m trying to proxy the location /forum with the discourse port.
It seems working but not completely, since the js files are loaded from the symfony2_root_folder/forum/.

I know how to solve this with nginx using alias, it’s just that I don’t know what’s the path of all the static files.

Can you help me fix this problem or lead me to a better nginx configuration ?
this is my nginx configuration:

server {
        	server_name myapp.com;
	return 301 http://www.myapp.com$request_uri;
}
#
server {
	server_name  www.myapp.com;

	root /usr/share/nginx/www/myapp.com/mainmyapp/web/;
	index app.php;
	try_files $uri $uri/ /app.php?$query_string;
	
	error_log /var/log/nginx/myapp.error.log;
    	access_log off;

    	   location /forum {
    	      alias /var/discourse/;
	      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	      proxy_set_header Host $http_host;
	      proxy_redirect off;
	      # pass to the upstream discourse server mentioned above
	      proxy_pass http://forum;
	   }

	location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ {
		expires 30d;
	       	add_header Vary Accept-Encoding;
	            access_log off;
	    }

	  location ~ ^/(app_dev|app_test.php|app)\.php(/|$) {
	  	try_files $uri =404;
		include fastcgi_params;
		fastcgi_pass php5-fpm-sock;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_intercept_errors on;
	  }
	  location /uploads/ { 
		location ~ .*\.(php).*$ 
		{ 
		deny all; 
		} 
	}
}	
  upstream forum {
  #fail_timeout is optional; I throw it in to see errors quickly
    server 127.0.0.1:86 fail_timeout=5;
  }

Subfolder support with Docker
(Rafael dos Santos Silva) #2

Inside /forum location you don’t want to use use alias and proxy_pass. Remove the alias directive.


(Quenten) #3

Removed it, still not working.


(Rafael dos Santos Silva) #4

Remove this

location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ {
		expires 30d;
	       	add_header Vary Accept-Encoding;
	            access_log off;
	    }

Rewrite so it is more specific to your other app: location /assets/.*\.(?:ico|css|js|gif|jpe?g|png|woff)$