Provide default apache and nginx configuration files

Describe the problem you would like to solve
Any OJS project that is in production will need to set up an nginx or apache webserver. Unfortunately, PKP does not provide any examples of what is required for the .conf files.

Describe the solution you’d like
I propose that the OJS project ships with default versions of the nginx and apache .conf files that should work on a standard linux server. The files could be named something like ojs-apache.conf.sample.

Who is asking for this feature?
I would like to set up my own OJS server for testing (on a remote VM, not locally), and eventually migrate our OJS instance from our library to a non-profit organization.

Additional information

Nice FR. Thanks!

This topic could be of interest to you:

As we host domain, subdomain, and folder journals (in single-tenant mode, behind a reverse-proxy), I have been dealing with Apache conf issues for years, and it is, by far, the most annoying and time-consuming task related to OJS that I have to do.

In the official container images I added a minimal/simplistic apache.conf, but this won’t cover usual/real production scenarios:

In this other project, you will see an extended version, but since it’s a template trying to cover all the bases, it’s probably too complex:

My conclusion, after all those years, is this is a really tricky petition because lot’s of things could collide (journal config.inc.php settings, proxy settings, domain/subdomain/folder url, protocol…) but I also think that would be great to have a commented htaccess.TEMPLATE for admins with generic recommendations about how to deal with different scenarios.

You got my vote.

Thanks, this is useful. But I really need help with nginx!

Well… I’ll deny having said this (I’m not a big fan of IAs), but LLMs have been doing a good job at translating for a while now, so you could start from the general “dojo” model, ground it in your context (there’s no point in creating rules for cases you’re not going to use), confirm that it works with Apache, and then ask it to translate those rules to nginx.

You’ll have to do some testing, but if you start from a correct config.inc.php and apache.conf, the move to nginx should be simpler.

I myself am now adapting the dojo rules to OJS 3.5, and it’s more or less the path I’m going to follow.

In any case, aside from specific problems in our contexts, a well-documented htaccess seems like a must for the collective project.

I’ve always used Nginx and these rules have been working just fine for OJS. Here is an example, that might be helpfull.

nginx.conf

http {
	# (...other rules...)
	
	upstream php8 {
          # set this to your server PHP configuration
          server unix:/run/php/php8.1-fpm.sock;
	}
	
	include my_ojs_server.conf;
}

my_ojs_server.conf

server {
	server_name my_ojs_server.com;
	# this is where OJS files are installed:
	root /var/www/my_ojs_server;
	
	location / {
		try_files $uri $uri/ /index.php$request_uri;
		include php8-fpm.conf;
	}
	
	# other general rules
	# include default_settings.conf;
}

php8-fpm.conf

location \~ \[^/\].php(/|$) {

  ## required for OJS to work - START ##
  set $path_info $fastcgi_path_info;
  fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  fastcgi_param 	PATH_INFO 				$path_info;
  fastcgi_param 	PATH_TRANSLATED 		$document_root$path_info;
  ## required for OJS to work - END ##
  
  fastcgi_param   QUERY_STRING            $query_string;
  fastcgi_param   REQUEST_METHOD          $request_method;
  fastcgi_param   CONTENT_TYPE            $content_type;
  fastcgi_param   CONTENT_LENGTH          $content_length;
  
  fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
  fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
  fastcgi_param   REQUEST_URI             $request_uri;
  fastcgi_param   DOCUMENT_URI            $document_uri;
  fastcgi_param   DOCUMENT_ROOT           $document_root;
  fastcgi_param   SERVER_PROTOCOL         $server_protocol;
  fastcgi_param  	REQUEST_SCHEME     		$scheme;
  fastcgi_param  	HTTPS              		$https if_not_empty;
  
  fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
  fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;
  
  fastcgi_param   REMOTE_ADDR             $remote_addr;
  fastcgi_param   REMOTE_PORT             $remote_port;
  fastcgi_param   SERVER_ADDR             $server_addr;
  fastcgi_param   SERVER_PORT             $server_port;
  fastcgi_param   SERVER_NAME             $server_name;
  
  #check upstream directive on nginx.conf
  fastcgi_pass php8; 
  fastcgi_read_timeout 240s;

}