Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - sharif779

#1
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
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
{
    "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.
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
#2
I want to change lighttpd to nginx as default web server. I have already installed and changed configuration in nginx server like lighttpd but api and ui routing is not working.
Here is my changed code for nginx configuration
server {
listen 80;

server_name _;

root /usr/local/www;
index index.php index.html;
        location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
       
        location /ui/{
    alias /usr/local/opnsense/www/;
    try_files $uri $uri/ /ui//ui/index.php?_url=$uri&$args;
    location ~ /ui/.+\.php$ {
                include fastcgi_params;
                fastcgi_buffers 256 4k;
                fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            }
        }

location /api/{
    alias /usr/local/opnsense/www/;
    try_files $uri $uri/ /api//api/api.php?_url=$uri&$args;
    location ~ /api/.+\.php$ {
                include fastcgi_params;
                fastcgi_buffers 256 4k;
                fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            }
        }

        location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
    }
}
   
After changing config api response is
{
    "message": "controller OPNsense\\Core\\Api\\IndexController not found",
    "status": 400
}

I have added IndexController though this controller was not in opnsense but it is not working at all.
Can you please help.It is needed to change web server .
#3
19.7 Legacy Series / Opnsense for debian
February 27, 2019, 12:51:42 PM
Is it possible to run opnsense in Debian environment though it is FreeBSD based.
#4
Dear all,
When I used get_interfaces_info() this function from interfaces.inc in my api controller then following error occurred
{"errorMessage":"[color=red]Error at /usr/local/etc/inc/interfaces.inc:4827 - Undefined index: status (errno=8)"}[/color] . But when I used same function on my static php page inside /usr/local/www/   there is no error occurred.

Is it possible that function inside api controller.If possible then how can I use it?
I am using 17.7 .