1
19.7 Legacy Series / Re: Convert lighttpd to nginx in Opnsense
« on: June 12, 2019, 07:15:17 am »
I am using opnsense 19.1 and there is no nginx.conf in opnsense src. But I found in opnsense git source .
I have added following code from https://github.com/opnsense/plugins/blob/master/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/webgui.conf
I access http://192.168.30.189/api/iop/dhcp/list this location but reply is
Here is my nginx configuration.
I have added following code from https://github.com/opnsense/plugins/blob/master/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/webgui.conf
Code: [Select]
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-webgui.socket;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param TLS-Cipher $ssl_cipher;
fastcgi_param TLS-Protocol $ssl_protocol;
fastcgi_param TLS-SNI-Host $ssl_server_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
# Phalcon ui and api routing
location @apirequest {
root /usr/local/opnsense/www;
include fastcgi_params;
fastcgi_param QUERY_STRING &$query_string;
fastcgi_param SCRIPT_FILENAME /usr/local/opnsense/www/api.php;
fastcgi_param TLS-Cipher $ssl_cipher;
fastcgi_param TLS-Protocol $ssl_protocol;
fastcgi_param TLS-SNI-Host $ssl_server_name;
fastcgi_intercept_errors off;
fastcgi_pass unix:/var/run/php-webgui.socket;
}
location @guirequest {
root /usr/local/opnsense/www;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SCRIPT_FILENAME /usr/local/opnsense/www/index.php;
fastcgi_param TLS-Cipher $ssl_cipher;
fastcgi_param TLS-Protocol $ssl_protocol;
fastcgi_param TLS-SNI-Host $ssl_server_name;
fastcgi_intercept_errors off;
fastcgi_pass unix:/var/run/php-webgui.socket;
}
location ~ ^/ui/(?<path>[^\?]+)(?<query>\?(.*))? {
root /usr/local/opnsense/www;
try_files /$path @guirequest;
}
location ~ ^/api/(?<path>[^\?]+)(?<query>\?(.*))?{
root /usr/local/opnsense/www;
try_files /$path @apirequest;
}
but same problem exists.I access http://192.168.30.189/api/iop/dhcp/list this location but reply is
Code: [Select]
{
"message": "controller OPNsense\\Core\\Api\\IndexController not found",
"status": 400
}
Can you please tell me the location of nginx.conf.Here is my nginx configuration.
Code: [Select]
server {
listen 80;
server_name _;
root /usr/local/www;
#compress.cache-dir = "/tmp/lighttpdcompress/"
gzip_types text/plain text/css text/xml text/javascript;
#server.upload-dirs = ( "/root/", "/tmp/", "/var/" )
# server.max-request-size = 2097152
expires 50h;
# Maximum idle time with nothing being written (php downloading)
#fastcgi_read_timeout = 999
## where to send error/access-messages to
access_log syslog:server=127.0.0.1,facility=daemon;
access_log /var/log/nginx/webgui.access.log;
error_log syslog:server=127.0.0.1,facility=daemon;
error_log /var/log/nginx/error.log debug;
index index.php index.html index.htm default.htm;
# mimetype mapping
types {
application/x-ns-proxy-autoconfig pad.dat;
application/pdf pdf;
application/pgp-signature sig;
application/futuresplash spl;
application/octet-stream class;
application/postscript ps;
application/x-bittorrent torrent;
application/x-dvi dvi;
application/x-gzip gz;
application/x-ns-proxy-autoconfig pac;
application/x-shockwave-flash swf;
application/x-tgz tar.gz tgz;
application/x-tar tar;
application/zip zip;
audio/mpeg mp3;
audio/x-mpegurl m3u;
audio/x-ms-wma wma;
audio/x-ms-wax wax;
audio/x-wav ogg;
audio/x-wav wav;
image/gif gif;
image/jpeg jpg jpeg;
image/png png;
image/svg+xml svg;
image/x-xbitmap xbm;
image/x-xpixmap xpm;
image/x-xwindowdump xwd;
text/css css;
text/html html htm;
text/javascript js;
text/plain asc;
text/plain c;
text/plain conf;
text/plain text txt;
text/xml dtd;
text/xml xml;
video/mpeg mpeg;
video/mpeg mpg;
video/quicktime mov qt;
video/x-msvideo avi;
video/x-ms-asf asf asx;
video/x-ms-wmv wmv;
application/x-bzip bz2;
application/x-bzip-compressed-tar tbz tar.bz2;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param TLS-Cipher $ssl_cipher;
fastcgi_param TLS-Protocol $ssl_protocol;
fastcgi_param TLS-SNI-Host $ssl_server_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
# Phalcon ui and api routing
location @apirequest {
root /usr/local/opnsense/www;
include fastcgi_params;
fastcgi_param QUERY_STRING &$query_string;
fastcgi_param SCRIPT_FILENAME /usr/local/opnsense/www/api.php;
fastcgi_param TLS-Cipher $ssl_cipher;
fastcgi_param TLS-Protocol $ssl_protocol;
fastcgi_param TLS-SNI-Host $ssl_server_name;
fastcgi_intercept_errors off;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location @guirequest {
root /usr/local/opnsense/www;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SCRIPT_FILENAME /usr/local/opnsense/www/index.php;
fastcgi_param TLS-Cipher $ssl_cipher;
fastcgi_param TLS-Protocol $ssl_protocol;
fastcgi_param TLS-SNI-Host $ssl_server_name;
fastcgi_intercept_errors off;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location ~ ^/ui/(?<path>[^\?]+)(?<query>\?(.*))? {
root /usr/local/opnsense/www;
try_files /$path @guirequest;
}
location ~ ^/api/(?<path>[^\?]+)(?<query>\?(.*))?{
root /usr/local/opnsense/www;
try_files /$path @apirequest;
}
}
FYI , I am using Opnsense in debian