How to publish my API specification using Apache? - swagger

I'm wondering whether it is possible to publish my RESP API specification in apache.
I tried to find an answer using Google, but I had no luck as there are a lot of "Apache Tomcat" or "Apache Licence" hits.
So I created my REST API specification using Swagger Editor and saved it as YAML, so I have my-api.yml.
What do I have to do now?

At the end what I did was, to download swagger-ui and I used dist folder.
I just modified URL in index.html directing to my API JSON file (I converted yml to jsom in Swagger Editor), which is sitting next to index.html.
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "my-api.json", // <-- change THIS
dom_id: '#swagger-ui',
The apache configuration was as simple as
<VirtualHost *:8080>
ServerName example.com
ServerAdmin admin#example.com
ServerAlias www.example.com
DocumentRoot /var/www/swagger
ErrorLog /var/www/swagger/logs/error.log
CustomLog /var/www/swagger/logs/requests.log combined
<Directory "/var/www/swagger">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>

Related

wampserver 404 error The requested URL was not found on this server

I installed wamp server and it works fine as the icon color is green and even the localhost works fine, but the problem happens when I add any PHP file inside www folder and try to access the file it gives me this message:
404 error The requested URL was not found on this server.
Any help will be appreciated.
How to run PHP project or files on wamp server at localhost?
Run wamp server
Create PHP project or file inside C://wamp/www/ directory.
Run your project or file means open URL in Browser ex: http://localhost/file_name.php or folder name
If a folder has an index.php file it will run by calling folder name in URL.
Running your project or file; means opening the URL in a browser
Example: 
http://localhost/file_name.php or folder name
You should check the httpd-vhosts.conf file via /wamp64/bin/apache/apache2.4.41/conf/extra/httpd-vhosts.conf. the follwings; the port numbers here for example 83 cause it was my choice:
# Virtual Hosts
#
<VirtualHost *:83>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:83>
ServerName myProject
DocumentRoot "d:/wamp64/www/spip-projet-v"
<Directory "d:/wamp64/www/spip-projet-v/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

URL routing on Bitnami Google Compute Ruby on Rails

I am attempting to deploy the sample rails app: https://github.com/railstutorial/sample_app_rails_4 to the Google Compute Engine using Bitnami. I have followed the wiki instructions to do so from: https://wiki.bitnami.com/Infrastructure_Stacks/BitNami_Ruby_Stack#How_can_I_deploy_my_Rails_application.3f
But upon attempting to access the url for the site, it still does not direct to the Rails app
as you can see here: http://www.1234-ok-go.com (a domain I have purchased) it simply goes to the base Ruby Stack success page.
Even though I have setup the httpd-vhosts.conf to specifically target the Rails App:
<VirtualHost *:80>
ServerName 1234-ok-go.com
DocumentRoot "/opt/bitnami/apps/myapp/htdocs/public"
Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:443>
ServerName 1234-ok-go.com
DocumentRoot "/opt/bitnami/apps/myapp/htdocs/public"
Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
</VirtualHost>
How can this issue be alleviated and route the URL to my Rails app?
Bitnami developer here.
After you had created your httpd-vhosts.conf (the one you pasted) file under installdir/apps/myapp/conf/ you have to append this line to /installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf
Include "/installdir/apps/myapp/conf/httpd-vhosts.conf"
And then create this file: /opt/bitnami/apps/myapp/conf/httpd-app.conf to look something like this:
<Directory /installdir/apps/myapp/htdocs/public>
Options +FollowSymLinks
AllowOverride None
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
PassengerEnabled on
PassengerAppRoot "/installdir/apps/myapp/htdocs"
</Directory>
And finally, restart apache:
<installdir>/ctlscript.sh restart apache

Tomcat7 / Apache2 URL Wildcard Mapping

I have a Java Servlet that takes the path of a provided URL request and retrieves database resources from it. For example:
www.mydomain.com/gateway/databasename/tablename
Would retrieve information from the specified table, all nice and REST like. This works just fine on a localhost Tomcat7 server on Windows and Netbeans, but I'm having trouble deploying it on an Apache2 web server running Ubuntu.
This is what my VirtualHost file looks like:
<VirtualHost *:80>
ServerAdmin andrew#mydomain.com
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/wordpress
<Directory />
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Alias /manager /usr/share/tomcat7-admin/manager
<Directory "/usr/share/tomcat7-admin/manager">
Options FollowSymLinks
AllowOverride None
Allow from all
</Directory>
JkMount /gateway* ajp13_worker
JkMount /manager* ajp13_worker
JkMount /host-manager* ajp13_worker
ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I'm able to navigate to www.mydomain.com/gateway and view the index page for the servlet. If I go to www.mydomain.com/gateway/databasename, I get a 404 error from Tomcat saying the requested resource is unavailable.
However! If I go to www.mydomain.com/gateway/gateway, I then get my servlet's response that "gateway" is an invalid database name.
So I think the problem is somewhere in the VirtualHost file and mapping the URL. Anything at www.mydomain.com/gateway/gateway/* works, but www.mydomain.com/gateway/* does not.
Also the servlet mapping for my deployment's web.xml is correct:
<servlet-mapping>
<servlet-name>Gateway</servlet-name>
<url-pattern>/gateway/*</url-pattern>
</servlet-mapping>
And the mod-jk's worker.properties file looks right:
worker.list=ajp13_worker
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
I'm not sure where I'm going wrong, and I know it's going to be something obvious. If anyone can help me out, I'd greatly appreciate it!
My guess is that Tomcat is serving the webapp at the / (root) context path when you run it from Netbeans, and the server is serving it at the /gateway context path.
So from Netbeans the base webapp path is: /hostname
But on the server it is: /hostname/gateway
Since the URL pattern of your servlet is /gateway/*, the result is that on the server you have to add an additional /gateway.
To fix it for the server, you need to change the URL pattern of your servlet to /* instead of /gateway/*
Then to make it work again from Netbeans, you need to change the context path from /ROOT to /gateway. I'm not familiar with Netbeans, but from a quick googling you need to right click your webapp go to Properties -> Run, and there you should be able to change the Context Path.

zend framework skeleton application not showing properly

I have installed the Skeleton Application manually. My application is kept in "D:\xampp\htdocs\zf2". I've created a virtual host in the following way, in httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName zf2
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
<Directory "D:/xampp/htdocs/zf2/public/index.php">
#DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
but it does not shown properly and it gives the output
and the remain ing application with module and database shows also not shows in the proper way
but if i slightly modify in virtual host settings of
DocumentRoot "D:/xampp/htdocs/zf2/public/index.php"
to
DocumentRoot "D:/xampp/htdocs/zf2/public"
then, skeleton application shows fine but when i configure module and database it gives error "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. zend sleleton application error"
can any one help me i have waste lot of time to set it but didn't.
You need to set document root to the folder not a file. The page looks messed up when pointing to index.php as documentroot because it cannot find the stylesheets.
The issue with configuring the module/database is probably a different issue, and you would have to post your module/database configuration to get help there.

Phusion Passenger not displaying CSS, Javascript files

I have a Phusion install, configured with Rails 3.0.10 and Apache 2, and assets like CSS and Javascript are apparently being served, but not utilized by the browser.
So for instance when I hit the root url, the page renders, but CSS and javascripts are not used by the browser. I see GET requests coming through for each asset in the access logs.
I can visit those assets directly in my browser, going to stylesheets/application.css?1313636333 I see the correct application.css
I dont see permission errors in production logs, or apache error logs.
My VHost looks like:
<VirtualHost *:80>
ServerAdmin info#example.com
ServerName portal.example.com
DocumentRoot /app/example/public
<Directory /app/example/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Since you can access your static assets, the mime-type incorrectness might be the cause.
Take the output of the following:
curl --head http://portal.example.com/stylesheets/application.css
the result should contains "Content-Type: text/css"

Resources